Re: Split with python

2006-08-30 Thread John Machin
tobiah wrote: > John Machin wrote: > > tobiah wrote: > > > >> Of course, fixing the csv file takes a little more work. It sounds like > >> the > >> test lines given were just one of the fields, and there are > >> the quotes to worry about. > >> > > [snip] > >> But then this fails if there are co

Re: Split with python

2006-08-30 Thread tobiah
John Machin wrote: > tobiah wrote: > >> Of course, fixing the csv file takes a little more work. It sounds like the >> test lines given were just one of the fields, and there are >> the quotes to worry about. >> > [snip] >> But then this fails if there are commas in the >> data. I could split an

Re: Split with python

2006-08-29 Thread Gabriel Genellina
At Tuesday 29/8/2006 20:31, tobiah wrote: >> I have a csv file which is has a field that has something like: >> But then this fails if there are commas in the data. I could split and join on '","' but then that fails when 'x' is either the first or last field. Are there tools in the csv module

Re: Split with python

2006-08-29 Thread bearophileHUGS
Norman Khine: > I have a csv file which is has a field that has something like: > "text (xxx)" > "text (text) (yyy)" > "text (text) (text) (zzz)" > > I would like to split the last '(text)' out and put it in a new column, > so that I get: > "text","(xxx)" > "text (text)","(yyy)" > "text (text) (tex

Re: Split with python

2006-08-29 Thread John Machin
tobiah wrote: > Of course, fixing the csv file takes a little more work. It sounds like the > test lines given were just one of the fields, and there are > the quotes to worry about. > [snip] > > But then this fails if there are commas in the > data. I could split and join on '","' but then > t

Re: Split with python

2006-08-29 Thread tobiah
Tim Chase wrote: > Norman Khine wrote: >> Hello, >> I have a csv file which is has a field that has something like: >> >> text.csv >> "text (xxx)" >> "text (text) (yyy)" >> "text (text) (text) (zzz)" >> >> I would like to split the last '(text)' out and put it in a new >> column, so that I get: >

Re: Split with python

2006-08-29 Thread John Machin
Tim Chase wrote: > Norman Khine wrote: > > Hello, > > I have a csv file which is has a field that has something like: > > > > text.csv > > "text (xxx)" > > "text (text) (yyy)" > > "text (text) (text) (zzz)" > > > > I would like to split the last '(text)' out and put it in a new column, > > so that

Re: Split with python

2006-08-29 Thread Tim Chase
Norman Khine wrote: > Hello, > I have a csv file which is has a field that has something like: > > text.csv > "text (xxx)" > "text (text) (yyy)" > "text (text) (text) (zzz)" > > I would like to split the last '(text)' out and put it in a new column, > so that I get: > > new_test.csv > "text","