parse a csv file into a text file

Zhen Zhang zhen.zhang.uoft at gmail.com
Thu Feb 6 08:56:51 CET 2014


On Wednesday, February 5, 2014 7:17:17 PM UTC-5, Asaf Las wrote:
> On Thursday, February 6, 2014 2:10:16 AM UTC+2, Zhen Zhang wrote:
> 
> > Hi, every one.
> 
> > Zhen
> 
> str_t = '3520005,"Toronto (Ont.)",C  ,F,2503281,2481494,F,F,0.9,1040597,979330,630.1763,3972.4,1' 
> 
> list_t = str_t.split(',')
> 
> print(list_t)
> 
> print("split result ", list_t[1], list_t[5])
> 
> print(list_t[1].split('"')[1])

Thanks for the reply,
I did not get the line 
str_t = '3520005,"Toronto (Ont.)",C  ,F,2503281,2481494,F,F,0.9,1040597,979330,630.1763,3972.4,1' 

I am processing a entire file not a line, so should i do 
str_t=line? maybe

list_t = str_t.split(',')
I think you are trying to spit a line into list.

but the line is already a list format right? that is why it allows me to do
something like line[1].
but I am not sure.



More information about the Python-list mailing list