I'm trying to pull data from a chart on a site in csv format. I've tried different combinations of code but can't seem to figure it out. I keep getting the following errors depending on the code I write:
TypeError: 'set' object is not subscriptable TypeError: a float is required
My latest attempt looked like this:
import urllib
import urllib2
import csv
import StringIO
url = "https://api.rjmetrics.com/0.1/chart/chartid/export"
headers = {"X-RJM-API-Key": "myapikey"}
data = {"format=csv"}
response = urllib2.Request(url, data, headers)
re = urllib2.urlopen(response)
spamreader = csv.reader(re, delimiter=',', quotechar='|')
for row in spamreader:
print row
The working CURL version looks like this:
curl -d "format=csv" -H "X-RJM-API-Key: myapikey" https://api.rjmetrics.com/0.1/chart/chartid/export
but I don't know how to work with curl.
Thank you!