Skip to content

Instantly share code, notes, and snippets.

@ivansaul
Created February 11, 2021 08:28
Show Gist options
  • Save ivansaul/28257e793ae9b8575bb5c0f1b3906dad to your computer and use it in GitHub Desktop.
Save ivansaul/28257e793ae9b8575bb5c0f1b3906dad to your computer and use it in GitHub Desktop.
Simplest Way of Reading Google Sheets into a Pandas Dataframe (Python)
import pandas as pd
#Create a public URL
#https://docs.google.com/spreadsheets/d/0Ak1ecr7i0wotdGJmTURJRnZLYlV3M2daNTRubTdwTXc/edit?usp=sharing
#get spreadsheets key from url
gsheetkey = "0Ak1ecr7i0wotdGJmTURJRnZLYlV3M2daNTRubTdwTXc"
#sheet name
sheet_name = 'Sheet 1'
url=f'https://docs.google.com/spreadsheet/ccc?key={gsheetkey}&output=xlsx'
df = pd.read_excel(url,sheet_name=sheet_name)
print(df)
@SolidHyunkel
Copy link

This code works and it helped me. Thank you!

@HgThinker
Copy link

Great thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment