Modifying a row in a textfile

Jorgen Grahn grahn+nntp at snipabacken.se
Sat Sep 12 09:52:07 EDT 2009


On Tue, 08 Sep 2009 14:21:59 +0200, Diez B. Roggisch <deets at nospam.web.de> wrote:
> Olli Virta wrote:
>
>> Hi!
>> 
>> I got a textfile made out of database records. Is there an easy way to
>> modify rows in that file in case you have to take away some items here
>> and there from each rows.
>
> for line in inf.readlines():
>     if matches_criteria(line):
>        line = modify_line(line)
>     outf.write(line)

In other words, no. You need to put the results in another file.

/Jorgen

-- 
  // Jorgen Grahn <grahn@  Oo  o.   .  .
\X/     snipabacken.se>   O  o   .



More information about the Python-list mailing list