"Inserting" a line in a text file?

Duncan Smith buzzard at urubu.freeserve.co.uk
Tue May 7 16:34:02 EDT 2002


I need to (in effect) insert a single line at the beginning of an existing
text file (a dumped MySQL database, so potentially large).  Is there
anything cuter than  eg. creating a temporary file containing the single
line, reading the lines from the data file, appending them to the temporary
file, deleting the data file, renaming the temporary file?  Currently on
Win2000, but the solution needs to be cross platform.  I can always go with
the obvious, but something faster and / or simpler would be nice (I might
even learn something).  Cheers.  TIA.

Duncan





More information about the Python-list mailing list