Skip to content

Instantly share code, notes, and snippets.

@copyleftdev
Last active February 19, 2016 20:39
Show Gist options
  • Select an option

  • Save copyleftdev/892ae902677a9a98f34c to your computer and use it in GitHub Desktop.

Select an option

Save copyleftdev/892ae902677a9a98f34c to your computer and use it in GitHub Desktop.
recursivly decompress bz2 file
for filename in files:
filepath = os.path.join(dirpath, filename)
newfilepath = os.path.join(dirpath, filename + '.decompressed')
with open(newfilepath, 'wb') as new_file, bz2.BZ2File(filepath, 'rb') as file:
for data in iter(lambda : file.read(100 * 1024), b''):
new_file.write(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment