Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40169
| From | io <maroso@libero.it> |
|---|---|
| Subject | Re: Read csv file and create a new file |
| Newsgroups | comp.lang.python |
| References | <512fac9c$0$40355$4fafbaef@reader1.news.tin.it> <512fb533$0$40355$4fafbaef@reader1.news.tin.it> <ap9s02Fuf0kU1@mid.individual.net> |
| Date | 2013-02-28 20:23 +0000 |
| Message-ID | <512fbcc7$0$40355$4fafbaef@reader1.news.tin.it> (permalink) |
| Organization | TIN.IT (http://www.tin.it) |
> 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! :-)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 19:14 +0000
Re: Read csv file and create a new file Neil Cerutti <neilc@norwich.edu> - 2013-02-28 19:32 +0000
Re: Read csv file and create a new file Joel Goldstick <joel.goldstick@gmail.com> - 2013-02-28 14:34 -0500
Re: Read csv file and create a new file Dave Angel <davea@davea.name> - 2013-02-28 14:35 -0500
Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 19:51 +0000
Re: Read csv file and create a new file Neil Cerutti <neilc@norwich.edu> - 2013-02-28 20:11 +0000
Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 20:23 +0000
Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 20:46 +0000
Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 20:51 +0000
Re: Read csv file and create a new file Dave Angel <davea@davea.name> - 2013-02-28 16:23 -0500
Re: Read csv file and create a new file io <maroso@libero.it> - 2013-02-28 22:05 +0000
Re: Read csv file and create a new file Dave Angel <davea@davea.name> - 2013-02-28 19:13 -0500
Re: Read csv file and create a new file Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-02-28 21:04 -0500
Re: Read csv file and create a new file io <maroso@libero.it> - 2013-03-04 19:04 +0000
Re: Read csv file and create a new file Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-04 23:58 +0000
csiph-web