Import Json web data source to xls or csv

pyplexed julius.welby at gmail.com
Wed Feb 20 11:47:08 CET 2013


Try something like:

for d in data:
    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've used 'is not None' in case 0 or 0.0 are acceptable bid or offer values. If you want to exclude rows with these values as well as None, you can just use:

for d in data:
    if d["bid"] and d["ask"]:
        # Do stuff

There are other ways to do this kind of thing, by the way. Check out list comprehensions sometime.



More information about the Python-list mailing list