Python append multiple files in given order to one big file

Just using simple file IO:

# tempfiles is a list of file handles to your temp files. Order them however you like
f = open("bigfile.txt", "w")
for tempfile in tempfiles:
    f.write(tempfile.read())

That’s about as OS agnostic as it gets. It’s also fairly simple, and the performance ought to be about as good as using anything else.

Leave a Comment