Created
February 19, 2014 01:59
-
-
Save davidbj/9084706 to your computer and use it in GitHub Desktop.
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
| I.Example of how to read a compressed file: | |
| import gzip | |
| f = gzip.open('file.tar.gz', 'rb') | |
| file_content = f.read() | |
| f.close() | |
| II.Example of how to create a compressed GZIP file: | |
| import gzip | |
| content = 'Lots of content here' | |
| f = gzip.open('file.txt.gz', 'wb') | |
| f.write(content) | |
| f.close() | |
| III.Example of how to GZIP compress an existing file: | |
| import gzip | |
| f_in = open('file.txt', 'rb') | |
| f_out = gzip.open('file.txt.gz', 'wb') | |
| f_out.writelines(f_in) | |
| f_out.close() | |
| f_in.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment