Created
June 12, 2015 00:27
-
-
Save carlohamalainen/14aedb34be4f862334a4 to your computer and use it in GitHub Desktop.
Join binary files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from functools import partial | |
import sys | |
BLOCKSIZE = 1048576 | |
# Similar to http://bugs.python.org/issue20992 | |
# but with Python 2.x syntax. | |
def read_blocks(files): | |
for filename in files: | |
with open(filename, "rb") as f: | |
for block in iter(partial(f.read, BLOCKSIZE), b''): | |
yield block | |
if __name__ == '__main__': | |
files = filter(lambda x: x != '', open(sys.argv[1], 'r').read().split('\n')) | |
output_file = sys.argv[2] | |
with open(output_file, 'wb') as f: | |
for block in read_blocks(files): | |
f.write(block) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment