"Inserting" a line in a text file?

William Park opengeometry at yahoo.ca
Tue May 7 17:02:21 EDT 2002


On Tue, May 07, 2002 at 09:34:02PM +0100, Duncan Smith wrote:
> 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.

Well, that's how I would do it... but, I'm on Linux.

-- 
William Park, Open Geometry Consulting, <opengeometry at yahoo.ca>
8-CPU Cluster, Hosting, NAS, Linux, LaTeX, python, vim, mutt, tin





More information about the Python-list mailing list