Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40141
| From | io <maroso@libero.it> |
|---|---|
| Subject | Import web content to csv only if values are different from those of an excel sheet |
| Newsgroups | comp.lang.python |
| Date | 2013-02-28 17:25 +0000 |
| Message-ID | <512f92fa$0$40355$4fafbaef@reader1.news.tin.it> (permalink) |
| Organization | TIN.IT (http://www.tin.it) |
Hi,
i have the following python script that reads json data from a website
and writes it in a csv file that i will then import to excel. (i have
just started since a week with py so i'm a noob!) :
-------------------------------------------------------
import json
import urllib
import csv
url = "http://bitcoincharts.com/t/markets.json"
response = urllib.urlopen(url);
data = json.loads(response.read())
f = open("/home/io/markets.csv","wb")
c = csv.writer(f)
# write headers
c.writerow(["Currency","Symbol","Bid", "Ask", "Volume"])
for d in data :
if d["currency"] <> "SLL": #esclude la valuta di secondlife SLL
if d["bid"] is not None and d["ask"] is not None:
c.writerow([str(d["currency"]),str(d["symbol"]),str(d
["bid"]),str(d["ask"]),str(d["currency_volume"])])
------------------------------------------------------
I have an .ods file (libre calc - i'm on linux) where i have in a sheet
called "exclusions" a list of names (symbol) the i want to exclude during
the import from web.
I would like to modify my script so that it can parse each row in the
"exclusion" sheet and if "symbol" = "parsed row value" then don't write
it to the csv file ... to loop on all values in the "exclusion" sheet.
I know it's certainly possible but i don't know how to do that. (if it
results easier having the exclusion list in a text file it's not a
problem, i'm not really stuck with librecalc!)
Thanks in advance to any helpful soul! :-)
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Import web content to csv only if values are different from those of an excel sheet io <maroso@libero.it> - 2013-02-28 17:25 +0000 Re: Import web content to csv only if values are different from those of an excel sheet Joel Goldstick <joel.goldstick@gmail.com> - 2013-02-28 14:13 -0500
csiph-web