Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Import Json web data source to xls or csv

Reply
Thread Tools

Re: Import Json web data source to xls or csv

 
 
rusi
Guest
Posts: n/a
 
      02-21-2013
On Feb 20, 6:54*am, Michael Herman <(E-Mail Removed)> wrote:
> First - you can use Python in Excel.http://www.python-excel.org/orhttps:...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?
 
Reply With Quote
 
 
 
 
Peter Otten
Guest
Posts: n/a
 
      02-21-2013
rusi wrote:

> On Feb 20, 6:54 am, Michael Herman <(E-Mail Removed)> wrote:
>> c = csv.writer(f)
>> c.writerow([str(d["currency"]),str(d["symbol"]),str(d["bid"]),
>> str(d["ask"]),str(d["currency_volume"])])


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


The actual differences: float values are converted using repr() instead of
str(), None values are converted to the empty str "".
Both special cases make sense to me. So

> Why do you use the str?



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Import Json web data source to xls or csv Michael Herman Python 0 02-20-2013 06:27 PM
Re: Import Json web data source to xls or csv Cousin Stanley Python 1 02-20-2013 10:47 AM
"JSON for ASP" at json.org Tuğrul Topuz ASP General 1 06-27-2008 11:37 PM
Using xtopdf, a PDF creation toolkit - Creating PDF Output from Plain Text, DBF, CSV, TDV, and XLS Data vasudevram Python 0 10-27-2006 06:07 PM
Packt published an article about xtopdf - creating PDF from PlainText, DBF, CSV, TDV, and XLS Data vasudevram Python 0 08-19-2006 01:38 PM



Advertisments