Re: [Tutor] overwriting input file

2009-02-25 Thread Kent Johnson
On Wed, Feb 25, 2009 at 1:53 PM, Alan Gauld wrote: > > "Bala subramanian" wrote > >> query 1) How should i overwrite the input file >> I want to open 5 files one by one, do some operation on the lines and >> write >> the modified lines on the same file (overwritting). Can some please tell >> me >

Re: [Tutor] overwriting input file

2009-02-25 Thread Alan Gauld
"Bala subramanian" wrote query 1) How should i overwrite the input file I want to open 5 files one by one, do some operation on the lines and write the modified lines on the same file (overwritting). Can some please tell me how to do it. You don't really want to do that! Too risky. Better

Re: [Tutor] overwriting input file

2009-02-25 Thread Kent Johnson
On Wed, Feb 25, 2009 at 8:26 AM, Noufal Ibrahim wrote: > Bala subramanian wrote: >> >> Hello all, >> >> query 1) How should i overwrite the input file >> I want to open 5 files one by one, do some operation on the lines and >> write the modified lines on the same file (overwritting). Can some plea

Re: [Tutor] overwriting input file

2009-02-25 Thread Noufal Ibrahim
A.T.Hofkamp wrote: write the output to a temporary file while reading the input, then rename the temporary file. This I believe is what the fileinput module does when you use it with the inplace parameter set to 1. -- ~noufal http://nibrahim.net.in/

Re: [Tutor] overwriting input file

2009-02-25 Thread Noufal Ibrahim
Bala subramanian wrote: Hello all, query 1) How should i overwrite the input file I want to open 5 files one by one, do some operation on the lines and write the modified lines on the same file (overwritting). Can some please tell me how to do it. import fileinput pat1=" R" pat2="U5" pat3="A

Re: [Tutor] overwriting input file

2009-02-25 Thread A.T.Hofkamp
Bala subramanian wrote: Hello all, query 1) How should i overwrite the input file I want to open 5 files one by one, do some operation on the lines and write the modified lines on the same file (overwritting). Can some please tell me how to do it. You cannot write output to a file if you need

[Tutor] overwriting input file

2009-02-25 Thread Bala subramanian
Hello all, query 1) How should i overwrite the input file I want to open 5 files one by one, do some operation on the lines and write the modified lines on the same file (overwritting). Can some please tell me how to do it. pat1=" R" pat2="U5" pat3="A3" from sys import argv files=argv[1:] for nam