diff --git a/module3/exo1/analyse-syndrome-grippal.ipynb b/module3/exo1/analyse-syndrome-grippal.ipynb index c7c0264dd5fdbabcb4739ed71617693baba89ae2..ffc1bcac2d695a8a25cc76ed705e857fd1a43ebd 100644 --- a/module3/exo1/analyse-syndrome-grippal.ipynb +++ b/module3/exo1/analyse-syndrome-grippal.ipynb @@ -17,38 +17,30 @@ "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import isoweek\n", - "import requests" + "import requests\n", + "import os" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "Les données de l'incidence du syndrome grippal sont disponibles du site Web du [Réseau Sentinelles](http://www.sentiweb.fr/). Nous les récupérons sous forme d'un fichier en format CSV dont chaque ligne correspond à une semaine de la période demandée. Nous téléchargeons toujours le jeu de données complet, qui commence en 1984 et se termine avec une semaine récente." + "Les données de l'incidence du syndrome grippal sont disponibles du site Web du [Réseau Sentinelles](http://www.sentiweb.fr/). Nous les récupérons sous forme d'un fichier en format CSV dont chaque ligne correspond à une semaine de la période demandée. Nous téléchargeons toujours le jeu de données complet, qui commence en 1984 et se termine avec une semaine récente.\n", + "De plus, on le télécharge dans un fichier local, si celui-ci n'existe pas encore." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "89422" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "data_file_name = \"incidence-PAY-3.csv\"\n", - "url = 'http://www.sentiweb.fr/datasets/' + data_file_name\n", - "r = requests.get(url, allow_redirects=True)\n", + "if not(os.path.isfile(data_file_name)):\n", + " url = 'http://www.sentiweb.fr/datasets/' + data_file_name\n", + " r = requests.get(url, allow_redirects=True)\n", "\n", - "open(data_file_name, 'wb').write(r.content)" + " open(data_file_name, 'wb').write(r.content)" ] }, { @@ -2223,7 +2215,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 9, @@ -2262,7 +2254,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 10, @@ -2366,7 +2358,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 13, @@ -2469,7 +2461,7 @@ { "data": { "text/plain": [ - "" + "" ] }, "execution_count": 15, diff --git a/module3/exo3/exercice.ipynb b/module3/exo3/exercice.ipynb index ac09dc2fe298d9dffefd6b8588de68d384af66e4..a5d2ec9c69630fd5a55af12a72e93dc7a6985870 100644 --- a/module3/exo3/exercice.ipynb +++ b/module3/exo3/exercice.ipynb @@ -10,7 +10,8 @@ "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "import isoweek\n", - "import requests" + "import requests\n", + "import os" ] }, { @@ -31,10 +32,10 @@ ], "source": [ "data_file_name = \"time_series_covid19_confirmed_global.csv\"\n", - "url = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/' + data_file_name\n", - "r = requests.get(url, allow_redirects=True)\n", - "\n", - "open(data_file_name, 'wb').write(r.content)" + "if not(os.path.isfile(data_file_name)):\n", + " url = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/' + data_file_name\n", + " r = requests.get(url, allow_redirects=True)\n", + " open(data_file_name, 'wb').write(r.content)" ] }, {