Last active
February 14, 2024 18:56
-
-
Save maxcollombin/a393ca29890ddd9c0623245f5109b917 to your computer and use it in GitHub Desktop.
Script to check the content of a zip file from a URL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
""" | |
checkzipurlcontent.py | |
Script to check the content of a zip file from a URL. | |
Author: [Maxime Collombin] | |
Date: [14/02/2023] | |
""" | |
import requests | |
import zipfile | |
import io | |
# URL of the zip file | |
ZIP_URL = "https://example.com/your-zip-file" | |
# Download the zip file | |
response = requests.get(ZIP_URL) | |
# Open the zip file in memory | |
zip_file = zipfile.ZipFile(io.BytesIO(response.content)) | |
# List the contents of the zip file and search for any .xlsx or .xls file | |
excel_files = [name for name in zip_file.namelist() if name.endswith(('.xlsx', '.xls'))] | |
if excel_files: | |
print("The zip file contains at least one Excel file.") | |
else: | |
print("The zip file does not contain any Excel file.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment