Import Json web data source to xls or csv

rusi rustompmody at gmail.com
Thu Feb 21 08:29:44 CET 2013


On Feb 20, 6:54 am, Michael Herman <herma... at gmail.com> wrote:
> First - you can use Python in Excel.http://www.python-excel.org/orhttps://www.datanitro.com/
>
> Updated code:
>
> import json
> import urllib
> import csv
>
> url = "http://bitcoincharts.com/t/markets.json"
> response = urllib.urlopen(url);
> data = json.loads(response.read())
>
> f = open("bitcoin.csv","wb")
> c = csv.writer(f)
>
> # write headers
> c.writerow(["Currency","Symbol","Bid", "Ask", "Volume"])
>
> for d in data:
>
> c.writerow([str(d["currency"]),str(d["symbol"]),str(d["bid"]),str(d["ask"]),str(d["currency_volume"])])



Looks neat.
Tried it with and without the str and there are small differences.

Why do you use the str?



More information about the Python-list mailing list