Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #39299

Re: Import Json web data source to xls or csv

References <51240f54$0$40361$4fafbaef@reader1.news.tin.it>
From Michael Herman <hermanmu@gmail.com>
Date 2013-02-19 17:54 -0800
Subject Re: Import Json web data source to xls or csv
Newsgroups comp.lang.python
Message-ID <mailman.2076.1361325293.2939.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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@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
>

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Import Json web data source to xls or csv io <maroso@libero.it> - 2013-02-19 23:48 +0000
  Re: Import Json web data source to xls or csv Michael Herman <hermanmu@gmail.com> - 2013-02-19 17:54 -0800
    Re: Import Json web data source to xls or csv io <maroso@libero.it> - 2013-02-20 07:13 +0000
      Re: Import Json web data source to xls or csv Michael Herman <hermanmu@gmail.com> - 2013-02-20 10:27 -0800
    Re: Import Json web data source to xls or csv rusi <rustompmody@gmail.com> - 2013-02-20 23:29 -0800
      Re: Import Json web data source to xls or csv Peter Otten <__peter__@web.de> - 2013-02-21 09:36 +0100
  Re: Import Json web data source to xls or csv Cousin Stanley <cousinstanley@gmail.com> - 2013-02-20 06:59 +0000
    Re: Import Json web data source to xls or csv io <maroso@libero.it> - 2013-02-20 08:19 +0000
      Re: Import Json web data source to xls or csv pyplexed <julius.welby@gmail.com> - 2013-02-20 02:47 -0800
        Re: Import Json web data source to xls or csv io <maroso@libero.it> - 2013-02-21 00:27 +0000

csiph-web