I am completely new to Python 3 and I'm very interested in learning how to open CSV data from websites. When I save a CSV to my local drive and run the following code it runs without issue:
import csv
with open("total_cases.csv") as covid:
covid_dict = csv.DictReader(covid)
for row in covid_dict:
print(row["Canada"])
I assumed that I could extrapolate this code to replace the local file name with the URL from which I downloaded that original CSV instead:
import csv
with open("https://covid.ourworldindata.org/data/ecdc/total_cases.csv") as covid:
covid_dict = csv.DictReader(covid)
for row in covid_dict:
print(row["Canada"])
When I do this, however, I obtain a no such directory or file error. Is there a trick I can use to make Python scan a CSV from a URL as opposed to from the local drive?