I'm trying to print a list of COVID cases for each country using https://covid.ourworldindata.org/data/owid-covid-data.json
Here is my code:
import json
f = open('covidData.json')
data = json.load(f)
new_string = json.dumps(data, indent =2)
for i in new_string['AFG']:
print(i)
f.close()
this only shows the data in "AFG" such as "continent", "location", etc. But I want to know how I can print "data" -> "new_cases"
I'm just learning python, but is there a syntax similar to ['AFG'.'data'.'new_cases']
that I can use to print the cases?
Extending this to the whole JSON file, can I upgrade my code so that I do not have to specify each country ID, rather use a general ['country'.'data'.'new_cases']
format to read the data?
Please let me know if anyone has any suggestions