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 @@ ...@@ -9,16 +9,15 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 3,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "source": [
"%matplotlib inline\n", "%matplotlib inline\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import pandas as pd\n", "import pandas as pd\n",
"import isoweek" "import isoweek\n",
"import os"
] ]
}, },
{ {
...@@ -30,13 +29,12 @@ ...@@ -30,13 +29,12 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 4,
"metadata": { "metadata": {},
"collapsed": true
},
"outputs": [], "outputs": [],
"source": [ "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 @@ ...@@ -63,12 +61,29 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 7,
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Local file is found. Downloading from local database\n"
]
}
],
"source": [ "source": [
"raw_data = pd.read_csv(data_url, skiprows=1)\n", "# Firstly, check if the local CSV file already exists.\n",
"raw_data" "# 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 @@ ...@@ -365,7 +380,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.6.1" "version": "3.6.4"
} }
}, },
"nbformat": 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