append one file to another
Steven D'Aprano
steve at REMOVETHIScyber.com.au
Tue Jul 12 10:53:21 EDT 2005
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) # 64 bytes at a time is a bit small...
> outfile.write(data)
Sorry, that should be in a loop:
data = "anything"
while data:
data = infile.read(64) # data will be empty when the file is read
outfile.write(data)
--
Steven.
More information about the Python-list
mailing list