How do I download and read the CSV data on this website using Python:
http://earthquake.usgs.gov/earthquakes/feed/csv/1.0/hour
It depends on what you want to do with the data. If you simply want to download the data you can use urllib2.
import urllib2
downloaded_data = urllib2.urlopen('http://...')
for line in downloaded_data.readlines():
print line
If you need to parse the csv you can use the urrlib2 and csv modules.
Python 2.X
import csv
import urllib2
downloaded_data = urllib2.urlopen('http://...')
csv_data = csv.reader(downloaded_data)
for row in csv_data:
print row
Python 3.X
import csv
import urllib.request
downloaded_data = urllib.request.urlopen('http://...')
csv_data = csv.reader(downloaded_data)
for row in csv_data:
print(row)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With