Every line of 'python unzip gz file' 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.
179 def _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()
25 def 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')
32 def 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)
44 def unzip(zip,dest): 45 import zipfile 46 zip_ref = zipfile.ZipFile(zip, 'r') 47 zip_ref.extractall(dest) 48 zip_ref.close()
22 def 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)
21 def unzip(filename): 22 """ Unzip the given file into another file. Return the new file's name. 23 24 :Returns: ``string`` 25 """ 26 if not iszip(filename): 27 raise ValueError("file %s is not zipped"%filename) 28 unzip_name, zipext = splitzipext(filename) 29 opener = file_openers[zipext] 30 outfile = file(unzip_name,'w') 31 outfile.write(opener(filename).read()) 32 outfile.close() 33 return unzip_name
24 def _decompress(filename): 25 zip_ref = zipfile.ZipFile(filename, 'r') 26 zip_ref.extractall(pyansys.EXAMPLES_PATH) 27 return zip_ref.close()
21 def _decompress(filename): 22 zip_ref = zipfile.ZipFile(filename, 'r') 23 zip_ref.extractall(pyvista.EXAMPLES_PATH) 24 return zip_ref.close()