Created
March 12, 2020 04:57
-
-
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NB - the latest data is not always tidy so proceed with caution