4 examples of 'python unzip file' in Python

Every line of 'python unzip 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
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()

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

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')
21def unzip(filename):
22 """ Unzip the given file into another file. Return the new file's name.
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
44def unzip(zip,dest):
45 import zipfile
46 zip_ref = zipfile.ZipFile(zip, 'r')
47 zip_ref.extractall(dest)
48 zip_ref.close()

Related snippets