How to merge two binary files into one?

Andrew Dalke dalke at dalkescientific.com
Tue Apr 5 01:57:30 EDT 2005


Grant Edwards wrote:
> For large files, something like this is probably a better idea:

Or with the little-used shutil module, and keeping your
nomenclature and block size of 65536

import shutil
fout = file('C', 'wb')
for n in ['A', 'B']:
  fin = file(n, 'rb')
  shutil.copyfileobj(fin, fout, 65536)
  fin.close()
fout.close()


				Andrew
				dalke at dalkescientific.com




More information about the Python-list mailing list