You can download this code by clicking the button below.
This code is now available for download.
This function is used to unzip files from a zip file to a specified directory. If the zip file is corrupted, it returns False.
Technology Stack : zipfile
Code Type : File operation
Code Difficulty : Intermediate
def zipfile_extract(file_path, extract_to_dir):
import zipfile
try:
with zipfile.ZipFile(file_path, 'r') as zip_ref:
zip_ref.extractall(extract_to_dir)
return True
except zipfile.BadZipFile:
return False