Ajout de commentaires sur l'implémentation de la sauvegarde locale.

parent e9483759
...@@ -17,38 +17,30 @@ ...@@ -17,38 +17,30 @@
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import pandas as pd\n", "import pandas as pd\n",
"import isoweek\n", "import isoweek\n",
"import requests" "import requests\n",
"import os"
] ]
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "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", "cell_type": "code",
"execution_count": 2, "execution_count": 2,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [],
{
"data": {
"text/plain": [
"89422"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"data_file_name = \"incidence-PAY-3.csv\"\n", "data_file_name = \"incidence-PAY-3.csv\"\n",
"url = 'http://www.sentiweb.fr/datasets/' + data_file_name\n", "if not(os.path.isfile(data_file_name)):\n",
"r = requests.get(url, allow_redirects=True)\n", " url = 'http://www.sentiweb.fr/datasets/' + data_file_name\n",
" r = requests.get(url, allow_redirects=True)\n",
"\n", "\n",
"open(data_file_name, 'wb').write(r.content)" " open(data_file_name, 'wb').write(r.content)"
] ]
}, },
{ {
...@@ -2223,7 +2215,7 @@ ...@@ -2223,7 +2215,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f124e1b07f0>" "<matplotlib.axes._subplots.AxesSubplot at 0x7fa958e6b9e8>"
] ]
}, },
"execution_count": 9, "execution_count": 9,
...@@ -2262,7 +2254,7 @@ ...@@ -2262,7 +2254,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f124c0d8ba8>" "<matplotlib.axes._subplots.AxesSubplot at 0x7fa956ccf4e0>"
] ]
}, },
"execution_count": 10, "execution_count": 10,
...@@ -2366,7 +2358,7 @@ ...@@ -2366,7 +2358,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f124bfb1160>" "<matplotlib.axes._subplots.AxesSubplot at 0x7fa956c61f98>"
] ]
}, },
"execution_count": 13, "execution_count": 13,
...@@ -2469,7 +2461,7 @@ ...@@ -2469,7 +2461,7 @@
{ {
"data": { "data": {
"text/plain": [ "text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f124bf81a20>" "<matplotlib.axes._subplots.AxesSubplot at 0x7fa956d39e48>"
] ]
}, },
"execution_count": 15, "execution_count": 15,
......
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import pandas as pd\n", "import pandas as pd\n",
"import isoweek\n", "import isoweek\n",
"import requests" "import requests\n",
"import os"
] ]
}, },
{ {
...@@ -31,10 +32,10 @@ ...@@ -31,10 +32,10 @@
], ],
"source": [ "source": [
"data_file_name = \"time_series_covid19_confirmed_global.csv\"\n", "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", "if not(os.path.isfile(data_file_name)):\n",
"r = requests.get(url, allow_redirects=True)\n", " url = 'https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/' + data_file_name\n",
"\n", " r = requests.get(url, allow_redirects=True)\n",
"open(data_file_name, 'wb').write(r.content)" " open(data_file_name, 'wb').write(r.content)"
] ]
}, },
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment