Skip to content

Instantly share code, notes, and snippets.

@nickjevershed
Created March 12, 2020 04:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nickjevershed/588671d485eace4bd5247da9707a1fb4 to your computer and use it in GitHub Desktop.
Save nickjevershed/588671d485eace4bd5247da9707a1fb4 to your computer and use it in GitHub Desktop.
Gets the latest data from the Johns Hopkins COVID-19 tracker, via GitHub
# This script will get the latest data from the Jons Hopkins GitHub repo https://github.com/CSSEGISandData
def getData():
import requests
files = [
"time_series_19-covid-Confirmed.csv",
"time_series_19-covid-Deaths.csv",
"time_series_19-covid-Recovered.csv"
]
headers = {'Accept': 'application/vnd.github.v3.raw'}
for path in files:
url = "https://api.github.com/repos/CSSEGISandData/COVID-19/contents/csse_covid_19_data/csse_covid_19_time_series/{path}".format(path=path)
print("Getting", path)
r = requests.get(url, headers=headers)
with open(path, 'w') as f:
f.write(r.text)
print("Files saved")
getData()
@nickjevershed
Copy link
Author

NB - the latest data is not always tidy so proceed with caution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment