Created
November 22, 2021 18:20
-
-
Save GabrielSGoncalves/1e4d8fd9a5801ff66878d23c94fb8476 to your computer and use it in GitHub Desktop.
Function for reading Google Sheets open to public
This file contains hidden or 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
from io import BytesIO | |
import requests | |
import pandas as pd | |
def read_public_sheets(file_url: str) -> pd.DataFrame: | |
"""Read a publicly available Google Sheets file as a Pandas Dataframe. | |
Parameters | |
---------- | |
file_url : str | |
URL adress to the spreadsheet CSV file. | |
Returns | |
------- | |
pd.DataFrame | |
Dataframe loaded from the CSV adress. | |
""" | |
response = requests.get(file_url) | |
return pd.read_csv(BytesIO(response.content)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment