automatically downloading data

This commit is contained in:
frankknoll
2022-05-13 19:29:45 +02:00
parent 2a95ad88bf
commit a9b6139e33
45 changed files with 242 additions and 83 deletions

View File

@@ -215,8 +215,7 @@
" else:\n",
" return None\n",
"\n",
"def downloadVAERSFile(file):\n",
" downloadDir = \"/home/frankknoll/Dokumente/Corona/projects/HowBadIsMyBatch/src/VAERS/tmp\"\n",
"def downloadVAERSFile(file, downloadDir):\n",
" driver = getWebDriver(downloadDir, isHeadless = False)\n",
" absoluteFile = downloadDir + \"/\" + file\n",
" downloadedFile = downloadFile(\n",
@@ -228,6 +227,30 @@
" return downloadedFile"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9ccc73b3",
"metadata": {},
"outputs": [],
"source": [
"import zipfile\n",
"\n",
"def unzip(zipFile, dstDir):\n",
" with zipfile.ZipFile(zipFile, 'r') as zip_ref:\n",
" zip_ref.extractall(dstDir)\n",
"\n",
"def unzipAndRemove(zipFile, dstDir):\n",
" unzip(zipFile, dstDir)\n",
" os.remove(zipFile)\n",
"\n",
"def downloadVAERSFileAndUnzip(file):\n",
" downloadedFile = downloadVAERSFile(file, \"/home/frankknoll/Dokumente/Corona/projects/HowBadIsMyBatch/src/VAERS/tmp\")\n",
" unzipAndRemove(\n",
" zipFile = downloadedFile,\n",
" dstDir = '/home/frankknoll/Dokumente/Corona/projects/HowBadIsMyBatch/src/VAERS/')\n"
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -236,10 +259,8 @@
"outputs": [],
"source": [
"if needsUpdate:\n",
" # FK-TODO: downloadVAERSFile('NonDomesticVAERSData.zip')\n",
" file = downloadVAERSFile('2022VAERSData.zip')\n",
" display('file: ', file)\n",
" # FK-TODO: 2022VAERSData.zip und NonDomesticVAERSData.zip an der richtigen Stelle auspacken"
" downloadVAERSFileAndUnzip('2022VAERSData.zip')\n",
" downloadVAERSFileAndUnzip('NonDomesticVAERSData.zip')"
]
},
{