Read csv file and create a new file
io
maroso at libero.it
Thu Feb 28 15:23:36 EST 2013
> Iterate over the file instead of looping manually.
>
> for line in esclusioni_file:
> esclusioni.append(line.strip())
> print(esclusioni)
the print was only to see if it was reading correct data but iìm not
needing to see it.
> Why are you checking d["symbol"] instead of d["currency"]? Maybe I
> misunderstood the question.
the file esclusioni.txt has the names of the market places that i want to
exclude ... the correspoding marketplace name is found in the symbol
value of the json imported data, that's why i'm comparing it with symbol.
> Test like this for either set or list container type. Use whichever json
> field is appropriate:
>
> if d["currency"] not in esclusioni:
>
>> c.writerow([str(d["currency"]),str(d["symbol"]),str(d
>> ["bid"]),str(d["ask"]),str(d["currency_volume"])])
>>
>> esclusioni.close()
that's a nice approach ( if d["symbol"] not in esclusioni: )!!!
Thanks i will give it a try ... i was getting crazy and my mind was
looping dangerously! :-)
More information about the Python-list
mailing list