Created
June 2, 2017 11:43
-
-
Save yassineAlouini/07543fa1debe1fb6aae817165c13d31a to your computer and use it in GitHub Desktop.
Compress a list of files using the BZ2 protocol.
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
import bz2 | |
import glob | |
for fp in glob.iglob('path/to_files'): | |
with open(fp, 'rb') as f_input: | |
with bz2.BZ2File(fp + '.bz2', 'wb', compresslevel=9) as f_output: | |
f_output.write(f_input.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment