Re: [Tutor] modify csv textfile

2010-08-07 Thread Sander Sweers
On 7 August 2010 13:45, TGW wrote: >> You can test if one item in your list begins with example like: >> ' example125 oo3 3456'.lstrip()[:7].lower() == 'example' > > I think I need to use regex here. Perhaps you will agree. You could but you don't have to, consider this. r = '1234|Avail|53|Potat

Re: [Tutor] modify csv textfile

2010-08-07 Thread David Hutto
On Sat, Aug 7, 2010 at 8:26 AM, David Hutto wrote: > On Sat, Aug 7, 2010 at 7:26 AM, Alan Gauld wrote: >> >> "TGW" wrote >>> >>> What I want to output is: >>> 12345|some text|some more text|example|example32423 >>> 11223|more text|and more|example|example455667 >>> >>> So column 4 is where the c

Re: [Tutor] modify csv textfile

2010-08-07 Thread David Hutto
On Sat, Aug 7, 2010 at 7:26 AM, Alan Gauld wrote: > > "TGW" wrote >> >> What I want to output is: >> 12345|some text|some more text|example|example32423 >> 11223|more text|and more|example|example455667 >> >> So column 4 is where the change occurs, but only if the beginning >> of the string in co

Re: [Tutor] modify csv textfile

2010-08-07 Thread Alan Gauld
"TGW" wrote What I want to output is: 12345|some text|some more text|example|example32423 11223|more text|and more|example|example455667 So column 4 is where the change occurs, but only if the beginning of the string in column 4 =~ /^example/i # and it should be case insensitive reader

Re: [Tutor] modify csv textfile

2010-08-07 Thread TGW
> You can test if one item in your list begins with example like: > ' example125 oo3 3456'.lstrip()[:7].lower() == 'example' I think I need to use regex here. Perhaps you will agree. Input file: 1119|Avail|53|Potato Chips 1234|Avail|53|Potato Chips and salse 1399|Avail|53|potato chips 1445|Avail|

Re: [Tutor] modify csv textfile

2010-08-07 Thread Sander Sweers
On 7 August 2010 04:35, TGW wrote: > I have a pipe delimited text file with 5 columns which looks like this: > 12345|some text|some more text|example125 oo3 3456|example32423 > 11223|more text|and more|example/73d 77665|example455667 > 12677|text|more|anotherexample 123|anotherexample45 > > What I

Re: [Tutor] modify csv textfile

2010-08-06 Thread James Mills
On Sat, Aug 7, 2010 at 12:35 PM, TGW wrote: > I have a pipe delimited text file with 5 columns which looks like this: > 12345|some text|some more text|example125 oo3 3456|example32423 > 11223|more text|and more|example/73d 77665|example455667 > 12677|text|more|anotherexample 123|anotherexample45 >

[Tutor] modify csv textfile

2010-08-06 Thread TGW
I have a pipe delimited text file with 5 columns which looks like this: 12345|some text|some more text|example125 oo3 3456|example32423 11223|more text|and more|example/73d 77665|example455667 12677|text|more|anotherexample 123|anotherexample45 What I want to output is: 12345|some text|some more t