I'm trying to get earthquake data, and turn it into an array so I can use that data to visualise earthquakes on a map. I'm writing this script:
import requests
import csv
def csv_to_array(a):
b = requests.get(a)
my_file = open(b, "rb")
for line in my_file:
el = [i.strip() for i in line.split(',')]
return el
which I import into another module, and:
import csvToArray
data = csvToArray.csv_to_array(
"http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_hour.csv")
i = 1
while i < len(data):
stuff = data[i].split(',')
print stuff[1], stuff[2]
lat = float(stuff[1])
lon = float(stuff[2])
x = webMercX(lon, zoom) - cx
y = webMercY(lat, zoom) - cy
i += 1
The other functions of above script are unnecessary but when I run it, I get the following error.
while i < len(data):
TypeError: object of type 'NoneType' has no len()

printdoesn't returns anything :), You are not returning anything fromcsv_to_arrayreturn