Skip to content

Instantly share code, notes, and snippets.

@JoeThunyathep
Last active April 16, 2020 12:16
Show Gist options
  • Save JoeThunyathep/58b9875bf00608e856b9e08752fcea0c to your computer and use it in GitHub Desktop.
Save JoeThunyathep/58b9875bf00608e856b9e08752fcea0c to your computer and use it in GitHub Desktop.
The example python script to download file from URL. This example downloads the German COVID-19 cases from RKI.
import urllib.request
from datetime import datetime
print("Start Program ... ")
try:
print("Start Downloading file ... ")
timenow = datetime.now()
timenow_iso = timenow.strftime('%Y-%m-%dT%H:%M:%S') #Time ISO to second resolution
url = 'https://opendata.arcgis.com/datasets/dd4580c810204019a7b8eb3e0b329dd6_0.csv' #url
output= f'data_RKI_{timenow_iso}.csv' # output's file name/ location
urllib.request.urlretrieve(url, output)
print(f"File {output} -- saved!")
except Exception as e:
print("Downloading file error: " + str(e))
## Continue your data analysis here...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment