Import Json web data source to xls or csv

io maroso at libero.it
Tue Feb 19 18:48:36 EST 2013


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 :-)



More information about the Python-list mailing list