file ops on the fly ?

Shagshag shagshag13 at yahoo.fr
Sat Jul 20 05:45:08 EDT 2002


"Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in message news:<mailman.1027083450.24075.python-list at python.org>...
> It can't be done.  Line deletion can be done using a
> dual-file-pointer algorithm, but if you can't load the
> dataset into RAM you can't do insertions without copying
> to another file.
> 
> Ur.  Maybe it can.  If you buffer a few lines ahead,
> rewriting them as you go...
> 
> I'm not even going to try to write the code for that.
> It's giving me a headache.

well, i think it's some kind of warning... 

i was also thinking of this mecanism, but my biggest trouble is how to
write the new file end ? and/or delete the last lines :

input_file.txt
1
2
3
4
5

need to replace 2, delete 3 and 5

output_file.txt
1
2b (this one was re-written)
4 (4 take 3 place)
4 (this line is un-wanted)
5 (and this line is also un-wanted)

s13.



More information about the Python-list mailing list