exercisemod3

parent 20abd168
This diff is collapsed.
This diff is collapsed.
......@@ -9,10 +9,8 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
......@@ -30,13 +28,40 @@
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Looking for file '%s' in the current directory... incidence-PAY-3.csv\n",
"'%s' not found! Downloading from internet... incidence-PAY-3.csv\n",
"'%s' download and saved locally.. incidence-PAY-3.csv\n"
]
}
],
"source": [
"data_url = \"http://www.sentiweb.fr/datasets/incidence-PAY-3.csv\""
"import os,sys\n",
"import urllib\n",
"def check_data_file(fname):\n",
" files = os.listdir(\".\") # get the current directory listing\n",
" print(\"Looking for file '%s' in the current directory...\",fname)\n",
"\n",
" if fname not in files:\n",
" print(\"'%s' not found! Downloading from internet...\",fname)\n",
" addr = \"https://www.sentiweb.fr/datasets/incidence-PAY-3.csv\"\n",
" response = urllib.request.urlopen(addr)\n",
" data = response.read()\n",
" fileOut = open(fname, \"wb\")\n",
" fileOut.write(data)\n",
" fileOut.close()\n",
" print(\"'%s' download and saved locally..\",fname)\n",
" else:\n",
" print(\"File found in current directory..\")\n",
" \n",
"INPUT_FILE = \"incidence-PAY-3.csv\"\n",
"check_data_file(INPUT_FILE)"
]
},
{
......@@ -365,7 +390,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