fix: Refactored parts of the script into functions
This commit is contained in:
parent
e13e8f1df6
commit
0e0ad8bc0f
1 changed files with 118 additions and 109 deletions
15
plot.py
15
plot.py
|
@ -52,16 +52,21 @@ plt.rcParams["figure.figsize"] = [11.69, 8.27]
|
||||||
|
|
||||||
# Download
|
# Download
|
||||||
|
|
||||||
data_filename = '{}/{}_Impfquotenmonitoring.xlsx'.format(data_folder, filename_now)
|
def download_rki(filename_prefix):
|
||||||
|
data_filename = '{}/{}_Impfquotenmonitoring.xlsx'.format(data_folder, filename_prefix)
|
||||||
|
|
||||||
r = req.get('https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquotenmonitoring.xlsx?__blob=publicationFile')
|
r = req.get('https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquotenmonitoring.xlsx?__blob=publicationFile')
|
||||||
|
|
||||||
with open(data_filename, 'wb') as outfile:
|
with open(data_filename, 'wb') as outfile:
|
||||||
outfile.write(r.content)
|
outfile.write(r.content)
|
||||||
|
|
||||||
#data_filename = 'data/20210118151908_Impfquotenmonitoring.xlsx'
|
return data_filename
|
||||||
|
|
||||||
rki_file = pd.read_excel(data_filename, sheet_name=None, engine='openpyxl')
|
data_filename = download_rki(filename_now)
|
||||||
|
|
||||||
|
def parse_rki(filename):
|
||||||
|
|
||||||
|
rki_file = pd.read_excel(filename, sheet_name=None, engine='openpyxl')
|
||||||
|
|
||||||
raw_data = rki_file['Impfungen_proTag']
|
raw_data = rki_file['Impfungen_proTag']
|
||||||
|
|
||||||
|
@ -196,6 +201,10 @@ m = stand_regex.match(stand)
|
||||||
stand_date = datetime.datetime.strptime(m.groups()[0], '%d.%m.%Y, %H:%M')
|
stand_date = datetime.datetime.strptime(m.groups()[0], '%d.%m.%Y, %H:%M')
|
||||||
print_stand = stand_date.isoformat()
|
print_stand = stand_date.isoformat()
|
||||||
|
|
||||||
|
return dates, start_of_reporting_date, data_first_vaccination, data_second_vaccination, stand_date, print_stand
|
||||||
|
|
||||||
|
dates, start_of_reporting_date, data_first_vaccination, data_second_vaccination, stand_date, print_stand = parse_rki(filename=data_filename)
|
||||||
|
|
||||||
filename_stand = stand_date.strftime("%Y%m%d%H%M%S")
|
filename_stand = stand_date.strftime("%Y%m%d%H%M%S")
|
||||||
|
|
||||||
print(f"Effective {stand_date}, last reported date {dates.iloc[-1].date()}")
|
print(f"Effective {stand_date}, last reported date {dates.iloc[-1].date()}")
|
||||||
|
|
Loading…
Reference in a new issue