Wednesday, August 19, 2020
Grabbing a web CSV file
I am tutoring an undergrad non-CS person on Python and we tried to graph some online data. This turned out to be pretty painful to get to work just because of versioning and encodings and my own lack of Python experience. But in the end it was super-smooth code because Python packages rule.
Here it is. The loop over counter is super kludgy. If you use this, improve that ;)
import matplotlib.pyplot as plt
url = 'https://data.london.gov.uk/download/historic-census-population/2c7867e5-3682-4fdd-8b9d-c63e289b92a6/census-historic-population-borough.csv'
response = urllib.request.urlopen(url)
cr = csv.reader( codecs.iterdecode(response, 'utf-8') )
x = 
y = 
for row in cr:
if counter == 3:
for j in range(2,len(row)):
counter=counter + 1