Skip to content

unzip_file

Source code in tinybig/util/utility.py
def unzip_file(complete_file_path: str, destination: str = None):
    if complete_file_path is None or not complete_file_path.endswith('.zip'):
        raise ValueError('file_name ending with .zip needs to be provided...')

    if destination is None:
        destination = os.path.dirname(complete_file_path)

    print(f"Unzipping: {complete_file_path}")
    with zipfile.ZipFile(complete_file_path, 'r') as zip_ref:
        zip_ref.extractall(destination)
    print(f"Unzipped: {complete_file_path}")