Created
April 12, 2018 22:19
-
-
Save mbforbes/89c6b4512cae460eca74b490d19c113b to your computer and use it in GitHub Desktop.
Python compress file
This file contains hidden or 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
def compress(bytes_path: str, compressed_path: str) -> None: | |
logging.info('Compressing "{}" to "{}"'.format( | |
bytes_path, compressed_path, | |
)) | |
with open(bytes_path, 'rb') as f_in: | |
with gzip.open(compressed_path, 'wb') as f_out: | |
shutil.copyfileobj(f_in, f_out) | |
logging.info('Removing "{}"'.format(bytes_path)) | |
os.remove(bytes_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment