Answers for "read google sheet to dataframe without google API"

0

read google sheet to dataframe without google API

#option1 (multiple sheets)
import pandas as pd
sheet_id = '1XqOtPkiE_Q0dfGSoyxrH730RkwrTczcRbDeJJpqRByQ'
sheet_name = 'sample_1'
url = f'https://docs.google.com/spreadsheets/d/{sheet_id}/gviz/tq?tqx=out:csv&sheet={sheet_name}'
data = pd.read_csv(url)    


#option2 (only one sheet)
sheet_url = 'https://docs.google.com/spreadsheets/d/1XqOtPkiE_Q0dfGSoyxrH730RkwrTczcRbDeJJpqRByQ/edit#gid=0'
url_1 = sheet_url.replace('/edit#gid=’, ‘/export?format=csv&gid=')
data = pd.read_csv(url_1)
Posted by: Guest on October-29-2021

Python Answers by Framework

Browse Popular Code Answers by Language