Commit the file

parent 42a2b992
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -9,16 +9,15 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import matplotlib.pyplot as plt\n",
"import pandas as pd\n",
"import isoweek"
"import isoweek\n",
"import os"
]
},
{
......@@ -30,13 +29,12 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"data_url = \"http://www.sentiweb.fr/datasets/incidence-PAY-3.csv\""
"data_url = \"http://www.sentiweb.fr/datasets/incidence-PAY-3.csv\"\n",
"local_FileName=\"incidence_data.csv\""
]
},
{
......@@ -63,12 +61,29 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Local file is found. Downloading from local database\n"
]
}
],
"source": [
"raw_data = pd.read_csv(data_url, skiprows=1)\n",
"raw_data"
"# Firstly, check if the local CSV file already exists.\n",
"# Secondly, if the file does not exist, download it from the official URL and save it locally.\n",
"# Thirdly,this ensures that the analysis uses a consistent local copy and avoids repeated downloads.\n",
"\n",
"if not os.path.exists(local_FileName):\n",
" print(\"Local file is not found. Downloading from the website\")\n",
" raw_data = pd.read_csv(data_url, skiprows=1)\n",
" raw_data.to_csv(local_FileName, index=False)\n",
"else:\n",
" print(\"Local file is found. Downloading from local database\")\n",
" raw_data = pd.read_csv(local_FileName)"
]
},
{
......@@ -365,7 +380,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