From c26a18d2059c8b484f025aeff5d9973fb114c6e2 Mon Sep 17 00:00:00 2001 From: d67f1d289df81656bf4e76b9db13fedf Date: Thu, 24 Nov 2022 22:03:47 +0000 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20commentaires=20sur=20l'impl=C3=A9m?= =?UTF-8?q?entation=20de=20la=20sauvegarde=20locale.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module3/exo1/analyse-syndrome-grippal.ipynb | 34 ++++++++------------- module3/exo3/exercice.ipynb | 11 ++++--- 2 files changed, 19 insertions(+), 26 deletions(-) diff --git a/module3/exo1/analyse-syndrome-grippal.ipynb b/module3/exo1/analyse-syndrome-grippal.ipynb index c7c0264..ffc1bca 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 ac09dc2..a5d2ec9 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)" ] }, { -- 2.18.1