[911] Read Data from Google Sheets into Pandas without the Google Sheets API (.gsheet)

发布时间 2023-10-18 13:18:35作者: McDelfino

ref: Read Data from Google Sheets into Pandas without the Google Sheets API


import pandas as pd
sheet_id = "1XqOtPkiE_Q0dfGSoyxrH730RkwrTczcRbDeJJpqRByQ"
sheet_name = "Sheet1"
url = f"https://docs.google.com/spreadsheets/d/{sheet_id}/gviz/tq?tqx=out:csv&sheet={sheet_name}"

You can find the sheet id in the url of your file behind “d/”, copy it from your browser and paste it into your code. The sheet name is the name you gave your sheet.