Import Json web data source to xls or csv

Michael Herman hermanmu at gmail.com
Tue Feb 19 20:54:28 EST 2013


First - you can use Python in Excel. http://www.python-excel.org/ or
https://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"])])



On Tue, Feb 19, 2013 at 3:48 PM, io <maroso at libero.it> wrote:

> Hi,
>
> i'm new to python and programming with it and so for json format.
> I have my excel 2010 program with vba that does the following :
>
> - read the data flow from http://bitcoincharts.com/t/markets.json
> - elaborate it and puts it in excel 2010 for further calculations
>
> What i'm willing to do is the same using Linux (xubuntu) and libreoffice.
>
> I thought learning python would be a smart idea for dealing with json
> format as it has a json library/module.
>
> How do i manage to read the data source from http://bitcoincharts.com/t/
> markets.json  and then place it in different cell of a new or existing
> xls worksheet?
>
> I'm trying some code with SPE but i can't sort the problem and i'm
> receiving many errors.
>
> I just need currency, symbol, bid, ask, volume
> This is the source code i was trying to use :
>
>
> import json
> import csv
> import urllib
>
> url = "http://bitcoincharts.com/t/markets.json"
> response = urllib.urlopen(url);
> data = json.loads(response.read())
>
> f = csv.writer(open('file.csv', 'wb+'))
> # use encode to convert non-ASCII characters
> for item in data:
>     values = [ x.encode('utf8') for x in item['0'].values() ]
>     f.writerow([item['currency'], item['high']] + values)
>
>
>
> Thanks for any help :-)
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130219/d1e5081c/attachment.html>


More information about the Python-list mailing list