ReadError: file could not be opened successfully tarfile.open code example

Example: file could not be opened successfully tarfile zip

import zipfile

def fetch_bank_data(banking_url=BANK_URL, banking_path=DATA_PATH):
    if not os.path.isdir(banking_path):
        os.makedirs(banking_path)
    zip_path = os.path.join(banking_path, "bank.zip")
    urllib.request.urlretrieve(banking_url, zip_path)
    
    with zipfile.ZipFile(zip_path, 'r') as banking_zip:
        banking_zip.extractall(banking_path)

    banking_zip.close()
    
fetch_bank_data()

Tags:

Misc Example