Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
jupyter-naas
GitHub Repository: jupyter-naas/awesome-notebooks
Path: blob/master/GitHub/GitHub_Download_Excel_file_from_URL.ipynb
2973 views
Kernel: Python 3

GitHub.png

GitHub - Download Excel file from URL

Give Feedback | Bug report

Tags: #github #excel #download #url #file #python

Last update: 2023-04-12 (Created: 2023-03-29)

Description: This notebook explains how to download an Excel file stored on a GitHub repository.

Input

Import libraries

import requests import pandas as pd

Setup Variables

  • url: URL of the Excel file stored on GitHub

  • output_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"

Model

Download Excel file

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)

Output

Display result

download_excel_file(url, output_path)