Re: append one file to another

2005-07-12 Thread John Machin
[EMAIL PROTECTED] wrote: > 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

Re: append one file to another

2005-07-12 Thread Steven D'Aprano
On Tue, 12 Jul 2005 07:38:39 -0700, [EMAIL PROTECTED] wrote: > Thanks for the nice suggestions! > > As a side question, you mentioned opening files in binary mode, in case > the code needs to run under Windows or cross-platform. What would > happen otherwise? Is it an issue of big little endian

Re: append one file to another

2005-07-12 Thread Grant Edwards
On 2005-07-12, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > As a side question, you mentioned opening files in binary > mode, in case the code needs to run under Windows or > cross-platform. What would happen otherwise? Is it an issue > of big little endian or some other issue? The end-of-line

Re: append one file to another

2005-07-12 Thread Danny Nodal
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(ope

Re: append one file to another

2005-07-12 Thread Steven D'Aprano
Dear me, replying to myself twice in one day... On Wed, 13 Jul 2005 00:39:14 +1000, Steven D'Aprano wrote: > Then, if you are concerned that the files really are huge, that is, as big > or bigger than the free memory your computer has, read and write them in > chunks: > > data = infile.read(64)

Re: append one file to another

2005-07-12 Thread [EMAIL PROTECTED]
Thanks for the nice suggestions! As a side question, you mentioned opening files in binary mode, in case the code needs to run under Windows or cross-platform. What would happen otherwise? Is it an issue of big little endian or some other issue? -- http://mail.python.org/mailman/listinfo/pytho

Re: append one file to another

2005-07-12 Thread Steven D'Aprano
On Tue, 12 Jul 2005 06:47:50 -0700, [EMAIL PROTECTED] wrote: > Hi, > > I want to append one (huge) file to another (huge) file. What do you call huge? What you or I think of as huge is not necessarily huge to your computer. > The current > way I'm doing it is to do something like: > > infile =

Re: append one file to another

2005-07-12 Thread Thomas Guettler
Am Tue, 12 Jul 2005 06:47:50 -0700 schrieb [EMAIL PROTECTED]: > 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.wri

append one file to another

2005-07-12 Thread [EMAIL PROTECTED]
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. -- h