Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python zip extract directory

import zipfile

archive = zipfile.ZipFile('archive.zip')

for file in archive.namelist():
    if file.startswith('foo/'):
        archive.extract(file, 'destination_path')
Comment

python extract zip file without directory structure

import os
import shutil
import zipfile

my_dir = r"D:Download"
my_zip = r"D:Downloadmy_file.zip"

with zipfile.ZipFile(my_zip) as zip_file:
    for member in zip_file.namelist():
        filename = os.path.basename(member)
        # skip directories
        if not filename:
            continue

        # copy file (taken from zipfile's extract)
        source = zip_file.open(member)
        target = open(os.path.join(my_dir, filename), "wb")
        with source, target:
            shutil.copyfileobj(source, target)
Comment

PREVIOUS NEXT
Code Example
Python :: how to create enter pressed for qlineedit in pyqt5 
Python :: what is seaborn in python 
Python :: 3 dimensional array in numpy 
Python :: generate binay image python 
Python :: python datetime offset 
Python :: find the highest 3 values in a dictionary. 
Python :: how to get the duration of audio python 
Python :: ln in python 
Python :: django python base 64 decode 
Python :: management commands django 
Python :: how do you write a function in python 
Python :: keras lstm example 
Python :: extract int from string python 
Python :: pandas categorical to numeric 
Python :: how to convert a list to dataframe in python 
Python :: how to iterate through a list in python 
Python :: python http request params 
Python :: multiple boxplots python 
Python :: how to multiply a string in python 
Python :: pandas change column dtype 
Python :: groupby and sort python 
Python :: python virtualenv 
Python :: python character list to string 
Python :: suppress python vs try/except pass 
Python :: python open file for reading and writing 
Python :: isdigit python 
Python :: Splitting training and test data using sklearn 
Python :: c++ vs python 
Python :: uninstall python using powershell 
Python :: join dataframe pandas by column 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =