added coditional local load

parent a5ee52a4
......@@ -57,10 +57,84 @@
"La première ligne du fichier CSV est un commentaire, que nous ignorons en précisant `skiprows=1`."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Here we save the freshly downlaoded csv file for better persistence, though we first test if we didn't do that previously.\n",
"The file will be saved in the current folder:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'/home/jovyan/work/module3/exo1'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import os\n",
"os.getcwd()"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"analyse-syndrome-grippal.ipynb\t influenza-like-illness-analysis.org\r\n",
"analyse-syndrome-grippal.org\t influenza-like-illness-analysis.Rmd\r\n",
"analyse-syndrome-grippal.Rmd\t my_csv.csv\r\n",
"influenza-like-illness-analysis.ipynb\r\n"
]
}
],
"source": [
"!ls /home/jovyan/work/module3/exo1"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"File exists, just loaded it !\n"
]
}
],
"source": [
"# if file does not exist, download and save\n",
"if not os.path.isfile(os.path.join('/home/jovyan/work/module3/exo1', 'my_csv.csv')):\n",
" print(\"File has been downloaded !\")\n",
" raw_data = pd.read_csv(data_url, skiprows=1)\n",
" raw_data.to_csv(os.path.join('/home/jovyan/work/module3/exo1', 'my_csv.csv'), index=False)\n",
"# if it exists just laod\n",
"else:\n",
" print(\"File exists, just loaded it !\")\n",
" raw_data = pd.read_csv(os.path.join('/home/jovyan/work/module3/exo1', 'my_csv.csv'))"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
......@@ -1024,13 +1098,12 @@
"[2118 rows x 10 columns]"
]
},
"execution_count": 3,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"raw_data = pd.read_csv(data_url, skiprows=1)\n",
"raw_data"
]
},
......@@ -1043,7 +1116,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 28,
"metadata": {},
"outputs": [
{
......@@ -1067,21 +1140,21 @@
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>week</th>\n",
" <th>indicator</th>\n",
" <th>inc</th>\n",
" <th>inc_low</th>\n",
" <th>inc_up</th>\n",
" <th>inc100</th>\n",
" <th>inc100_low</th>\n",
" <th>inc100_up</th>\n",
" <th>geo_insee</th>\n",
" <th>geo_name</th>\n",
" <th>202522</th>\n",
" <th>3</th>\n",
" <th>20831</th>\n",
" <th>15052.0</th>\n",
" <th>26610.0</th>\n",
" <th>31</th>\n",
" <th>22.0</th>\n",
" <th>40.0</th>\n",
" <th>FR</th>\n",
" <th>France</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1881</th>\n",
" <th>1880</th>\n",
" <td>198919</td>\n",
" <td>3</td>\n",
" <td>-</td>\n",
......@@ -1098,14 +1171,11 @@
"</div>"
],
"text/plain": [
" week indicator inc inc_low inc_up inc100 inc100_low inc100_up \\\n",
"1881 198919 3 - NaN NaN - NaN NaN \n",
"\n",
" geo_insee geo_name \n",
"1881 FR France "
" 202522 3 20831 15052.0 26610.0 31 22.0 40.0 FR France\n",
"1880 198919 3 - NaN NaN - NaN NaN FR France"
]
},
"execution_count": 4,
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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