Skip to content

covid19datahub/Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Interface to COVID-19 Data Hub

Python csv parser csv.reader() does not seem to parse the csv well, since it cannot work with the quotation marks around strings.

However read_csv() from pandas is processing it fine.

To make a successful call, you also have to specify User-Agent header, see here, the request is hence sent separately using requests library.

Install pandas and requests by typing into terminal:

pip install pandas requests

Once installed, fetch the data:

# standard library
from io import StringIO
# nonstandard - download separately
import pandas as pd # Pandas
import requests # HTTP Request library
# download
url = "https://storage.covid19datahub.io/data-1.csv"
response = requests.get(url, headers = {"User-Agent": "Mozilla/5.0"})
# make response iterable string
data = StringIO(response.text)
# load into pandas
df = pd.read_csv(data)

Packages

 
 
 

Contributors