Python: Compress/Decompress Gzip Files
Compress gzip File
# compress a gzip file import gzip input = open("/Users/joe/xxtest", 'rb') s = input.read() input.close() output = gzip.GzipFile("/Users/joe/xxtest.gz", 'wb') output.write(s) output.close() print("done")
Decompress gzip File
# decompress a gzip file import gzip input = gzip.GzipFile("/Users/joe/xxtest.gz", 'rb') s = input.read() input.close() output = open("/Users/joe/xxtest", 'wb') output.write(s) output.close() print("done")