append one file to another

Danny Nodal dnodal at charter.net
Tue Jul 12 10:52:47 EDT 2005


Its been a while since I last coded in Python, so please make sure you test
it before trying it so you don't clobber your existing file. Although it may
not be more effecient than what you are doing now or has been suggested
already, it sure cuts down on the typing.

open(outfilename,'a').write(open(infilename).read())

Regards.

<b83503104 at yahoo.com> wrote in message
news:1121176070.045217.264890 at g44g2000cwa.googlegroups.com...
> Hi,
>
> I want to append one (huge) file to another (huge) file.  The current
> way I'm doing it is to do something like:
>
> infile = open (infilename, 'r')
> filestr = infile.read()
> outfile = open(outfilename, 'a')
> outfile.write(filestr)
>
> I wonder if there is a more efficient way doing this?
> Thanks.
>





More information about the Python-list mailing list