6 examples of 'unzip gz file python' in Python

Every line of 'unzip gz file python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
179def _PythonUnzip(self):
180 """Unzip a file using the python zipfile module."""
181 ziplocal = None
182 try:
183 ziplocal = zipfile.ZipFile(self._zipfile_name)
184 ziplocal.extractall()
185 finally:
186 if ziplocal is not None:
187 ziplocal.close()
25def unzip_file():
26 """Unzip to folder"""
27 if os.path.isdir('raw_grid'):
28 print("Files already extracted")
29 else:
30 print("Extracting files")
31 with zipfile.ZipFile('grid_affil.zip', 'r') as zip_file:
32 zip_file.extractall('raw_grid')
32def main(gzip_filename):
33 print('[zlib C lib version (used by Python zlib module): {}]'.format(zlib.ZLIB_VERSION))
34 gzip_file_size = os.path.getsize(gzip_filename) # in bytes
35 with gzip.GzipFile(gzip_filename) as gunzipped_file_obj:
36 gzip_lib_uncompressed_data = gunzipped_file_obj.read()
37 print(' -> CRC32 COMPUTED FROM DATA DECOMPRESSED WITH gzip: {}'.format(zlib.crc32(gzip_lib_uncompressed_data) & 0xffffffff))
38 print(' -> LENGTH OF ACTUAL DATA DECOMPRESSED with gzip : {} bytes'.format(len(gzip_lib_uncompressed_data)))
39 with open(gzip_filename, 'rb') as gzip_file:
40 data = gzip_file.read()
41 manually_uncompress(data)
22def compress(file):
23 with open(file, 'rb') as f_in:
24 with gzip.open(file + ".gz", "wb") as f_out:
25 shutil.copyfileobj(f_in, f_out)
24def _decompress(filename):
25 zip_ref = zipfile.ZipFile(filename, 'r')
26 zip_ref.extractall(pyansys.EXAMPLES_PATH)
27 return zip_ref.close()
21def _decompress(filename):
22 zip_ref = zipfile.ZipFile(filename, 'r')
23 zip_ref.extractall(pyvista.EXAMPLES_PATH)
24 return zip_ref.close()

Related snippets