Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'data:': 0.07; 'json': 0.07; 'puts': 0.07; 'python': 0.09; 'encode': 0.09; 'non-ascii': 0.09; 'cc:addr:python-list': 0.10; ':-)': 0.13; 'csv': 0.16; 'currency,': 0.16; 'spe': 0.16; 'symbol,': 0.16; 'url:json': 0.16; 'urllib': 0.16; 'wrote:': 0.17; 'headers': 0.17; 'feb': 0.19; 'sort': 0.21; 'trying': 0.21; 'import': 0.21; 'cc:2**0': 0.23; 'programming': 0.23; 'cc:no real name:2**0': 0.24; 'idea': 0.24; 'linux': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'values': 0.26; 'errors.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'smart': 0.29; 'url:mailman': 0.29; 'convert': 0.29; 'skip:& 10': 0.29; 'source': 0.29; "i'm": 0.29; 'code': 0.31; 'url:python': 0.32; 'url:listinfo': 0.32; 'skip:j 20': 0.33; 'subject:data': 0.33; 'problem': 0.33; 'code:': 0.33; 'excel': 0.33; 'hi,': 0.33; 'skip:& 20': 0.33; "can't": 0.34; 'received:google.com': 0.34; 'updated': 0.34; 'thanks': 0.34; 'pm,': 0.35; 'received:209.85': 0.35; 'skip:u 20': 0.36; 'but': 0.36; 'url:org': 0.36; 'characters': 0.36; 'flow': 0.36; 'does': 0.37; 'item': 0.37; 'received:209': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'skip:o 20': 0.38; 'some': 0.38; 'help': 0.40; 'url:mail': 0.40; 'further': 0.61; 'first': 0.61; 'different': 0.63; 'url:t': 0.65; '2013': 0.84; 'ask,': 0.84; 'calculations': 0.84; 'subject:Import': 0.84; 'subject:source': 0.84; 'to:addr:libero.it': 0.84; 'vba': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=TW234i78uVZGm+VxGhFFDbtHwqRvLzpsJAGlEhXdkFQ=; b=u1HK0ElbTsRvaDLxTfP9/DrVUc6Nnhdgb/Zj17ivCS25Yf4z/Z11GLcUZRVhMDBvRs HKqtXbRYq7fASKGWQJiHsa3+s93iA4mWE4Li81vcF5WhOVSBQtgPle9q4bNUCODHc+2H FkXhlqXuuAxXmrOV6NXyTzeiQLj9U5zEDD7rljdeSbArOBtF76lBkSrWHQ/jV6FdnwKI c5I9Iz7vpfdjYC1k9LgT83Sy7zzc00/ShlVeqacbPArvx7t942qLGAFbquOcqnRpLOMx 5qAI6F6QZNvAFuNE0qTPrB5ECVOWABF2WZCGV0/Hcc1uZzIu2VY+55YTP/rnnGX8BugK yMvw== X-Received: by 10.58.106.35 with SMTP id gr3mr23799198veb.51.1361325290503; Tue, 19 Feb 2013 17:54:50 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <51240f54$0$40361$4fafbaef@reader1.news.tin.it> References: <51240f54$0$40361$4fafbaef@reader1.news.tin.it> From: Michael Herman Date: Tue, 19 Feb 2013 17:54:28 -0800 Subject: Re: Import Json web data source to xls or csv To: io Content-Type: multipart/alternative; boundary=047d7b677ee65d3c8e04d61e3ebb Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 162 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1361325293 news.xs4all.nl 6951 [2001:888:2000:d::a6]:49452 X-Complaints-To: abuse@xs4all.nl Path: csiph.com!usenet.pasdenom.info!news.franciliens.net!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Xref: csiph.com comp.lang.python:39299 --047d7b677ee65d3c8e04d61e3ebb Content-Type: text/plain; charset=ISO-8859-1 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 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 > --047d7b677ee65d3c8e04d61e3ebb Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable First - you can use Python in Excel.=A0http://www.python-excel.org/ or=A0https://www.datanitro.com/

Updated code:

import json
import urllib
import cs= v

response =3D urllib.urlopen(url);
data =3D json.loads(response.re= ad())

f =3D open("bitcoin.csv","wb&= quot;)
c =3D csv.writer(f)

# write heade= rs
c.writerow(["Currency","Symbol","Bid", &= quot;Ask", "Volume"])


for d in data:
=A0 =A0 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@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 libreoffic= e.

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 =A0and 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= 9;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 =3D "http://bitcoincharts.com/t/markets.json"
response =3D urllib.urlopen(url);
data =3D json.loads(response.read())

f =3D csv.writer(open('file.csv', 'wb+'))
# use encode to convert non-ASCII characters
for item in data:
=A0 =A0 values =3D [ x.encode('utf8') for x in item['0'].va= lues() ]
=A0 =A0 f.writerow([item['currency'], item['high']] + value= s)



Thanks for any help :-)
--
http://mail.python.org/mailman/listinfo/python-list

--047d7b677ee65d3c8e04d61e3ebb--