Fonction écriture en local

parent 4add1110
...@@ -32,12 +32,13 @@ ...@@ -32,12 +32,13 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"# URL du fichier de données\n",
"data_url = \"http://www.sentiweb.fr/datasets/incidence-PAY-3.csv\"" "data_url = \"http://www.sentiweb.fr/datasets/incidence-PAY-3.csv\""
] ]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 5, "execution_count": 8,
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
{ {
...@@ -49,11 +50,15 @@ ...@@ -49,11 +50,15 @@
} }
], ],
"source": [ "source": [
"# Vérification de la présence du fichier en local\n",
"# Si non, téléchargement à partir de l'URL\n",
"import os.path\n", "import os.path\n",
"# Vérifier si le fichier existe ou non\n", "# Vérifier si le fichier existe ou non\n",
"if os.path.isfile('incidence-PAY-3.csv'):\n", "if os.path.isfile('incidence-PAY-3.csv'):\n",
" print(\"Fichier trouvé\")\n", " print(\"Fichier trouvé\")\n",
" raw_data = pd.read_csv('incidence-PAY-3.csv', skiprows=1)\n", " raw_data = pd.read_csv('incidence-PAY-3.csv', skiprows=1)\n",
" # Ecrituredu fichier en local\n",
" raw_data.to_csv('incidence-PAY-3.csv')\n",
"else:\n", "else:\n",
" print(\"Fichier non trouvé\")\n", " print(\"Fichier non trouvé\")\n",
" print(\"Téléchargement du fichier sur le site Web\")\n", " print(\"Téléchargement du fichier sur le site Web\")\n",
......
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