Exercice 1 TP

parent 9a5543b7
......@@ -16,7 +16,9 @@
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import isoweek"
"import isoweek\n",
"import os\n",
"import urllib.request"
]
},
{
......@@ -37,6 +39,35 @@
"data_url = \"http://www.sentiweb.fr/datasets/incidence-PAY-3.csv\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"local_filename = \"incidence-PAY-3.csv\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Télécharger si le fichier local n'existe pas"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
" if not os.path.exists(local_filename):\n",
" print(\"Téléchargement du fichier\")\n",
" urllib.request.urlretrieve(data_url, local_filename)\n",
"else:\n",
" print(\"Fichier déjà présent localement.\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
......@@ -65,7 +96,7 @@
"metadata": {},
"outputs": [],
"source": [
"raw_data = pd.read_csv(data_url, skiprows=1)\n",
"raw_data = pd.read_csv(local_filename, skiprows=1)\n",
"raw_data"
]
},
......@@ -364,7 +395,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
"version": "3.6.4"
}
},
"nbformat": 4,
......
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