Template request | Bug report | Generate Data Product
Tags: #github #excel #download #url #file #python
Author: Florent Ravenel
Description: This notebook explains how to download an Excel file stored on a GitHub repository.
References:
import requests
import pandas as pd
url
: URL of the Excel file stored on GitHuboutput_path
: Name of the output to be saved on your local
# Inputs
url = "https://github.com/jupyter-naas/awesome-notebooks/blob/master/Excel/Conso.xlsx"
# Outputs
output_path = "Excel.xlsx"
def download_excel_file(url, output_path):
# Check URL
if not url.endswith("?raw=true") and url.endswith(".xlsx"):
url = f'{url}?raw=true'
# Get file
response = requests.get(url)
with open(output_path, "wb") as f:
f.write(response.content)
print("✅ Excel file successfully saved:", output_path)
download_excel_file(url, output_path)