From ae7d21b2a3f9a9e8c5b034e0a8cd47a19eec4b57 Mon Sep 17 00:00:00 2001 From: Benedikt Bastin Date: Fri, 15 Jan 2021 01:01:43 +0100 Subject: [PATCH] feat: File now will be downloaded when running the script --- plot.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/plot.py b/plot.py index 8ccb077..246eb35 100644 --- a/plot.py +++ b/plot.py @@ -4,14 +4,33 @@ import pandas as pd import datetime import re +import requests as req + einwohner_deutschland = 83190556 +today = datetime.date.today() +print_today = today.isoformat() + +filename_now = datetime.datetime.now().strftime("%Y%m%d%H%M%S") # DIN A4 Plots plt.rcParams["figure.figsize"] = [11.69, 8.27] -rki_file = pd.read_excel('Impfquotenmonitoring.xlsx', sheet_name=None, engine='openpyxl') + +# Download + +filename = '{}_Impfquotenmonitoring.xlsx'.format(filename_now) + +r = req.get('https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquotenmonitoring.xlsx?__blob=publicationFile') + +with open(filename, 'wb') as outfile: + outfile.write(r.content) + + + + +rki_file = pd.read_excel(filename, sheet_name=None, engine='openpyxl') raw_data = rki_file['Impfungen_proTag'] @@ -50,7 +69,6 @@ def plot_extrapolation_portion(percentage): fig, ax = plt.subplots(1) print_percentage = int(percentage * 100) - print_today = datetime.date.today().isoformat() plt.title( 'Tägliche Impfquote, kumulierte Impfungen und lineare Extrapolation bis {} % der Bevölkerung Deutschlands\n'