October 2019
Beginner to intermediate
674 pages
16h 43m
English
json_loads is used to read a physical file containing JSONs:
f=open('usagov_bitly.txt','r').readline() json.loads(f)
We get the following output:

The files can be read one JSON at a time using the open and readline methods:
records=[] f=open('usagov_bitly.txt','r') for i in range(1000): fiterline=f.readline() d=json.loads(fiterline) records.append(d) f.close()
Now, records contains a list of JSONs from which all the values of a particular key can be pulled out. For example, here, we are pulling out all the latlong ('ll' column) wherever it has a non-zero value:
latlong=[rec['ll'] for rec in ...
Read now
Unlock full access