<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Feb 28, 2013 at 12:25 PM, io <span dir="ltr"><<a href="mailto:maroso@libero.it" target="_blank">maroso@libero.it</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
i have the following python script that reads json data from a website<br>
and writes it in a csv file that i will then import to excel. (i have<br>
just started since a week with py so i'm a noob!) :<br>
-------------------------------------------------------<br>
<br>
import json<br>
import urllib<br>
import csv<br>
<br>
url = "<a href="http://bitcoincharts.com/t/markets.json" target="_blank">http://bitcoincharts.com/t/markets.json</a>"<br>
response = urllib.urlopen(url);<br>
data = json.loads(response.read())<br>
<br>
f = open("/home/io/markets.csv","wb")<br>
c = csv.writer(f)<br>
<br>
# write headers<br>
c.writerow(["Currency","Symbol","Bid", "Ask", "Volume"])<br>
<br>
for d in data :<br>
    if d["currency"] <> "SLL":  #esclude la valuta di secondlife SLL<br>
        if d["bid"] is not None and d["ask"] is not None:<br>
            c.writerow([str(d["currency"]),str(d["symbol"]),str(d<br>
["bid"]),str(d["ask"]),str(d["currency_volume"])])<br>
<br>
------------------------------------------------------<br>
<br>
I have an .ods file (libre calc - i'm on linux) where i have in a sheet<br>
called "exclusions" a list of names (symbol) the i want to exclude during<br>
the import from web.<br></blockquote><div><br></div><div>If you could output this file as csv you don't have a difficult problem.  If you can't, I found this:  <a href="http://stackoverflow.com/questions/4745024/spreadsheet-to-python-dictionary-conversion">http://stackoverflow.com/questions/4745024/spreadsheet-to-python-dictionary-conversion</a><br>
</div><div>which discusses reading ods files. <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I would like to modify my script so that it can parse each row in the<br>
"exclusion" sheet and if "symbol"  = "parsed row value" then don't write<br>
it to the csv file ... to loop on all values in the "exclusion" sheet.<br>
<br>
I know it's certainly possible but i don't know how to do that.  (if it<br>
results easier having the exclusion list in a text file it's not a<br>
problem, i'm not really stuck with librecalc!)<br>
<br>
Thanks in advance to any helpful soul!  :-)<br>
<span class=""><font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr"><div>Joel Goldstick<br></div><a href="http://joelgoldstick.com" target="_blank">http://joelgoldstick.com</a><br></div>
</div></div>