I have a simple publicly shared and published google sheet, I am trying to print the title of the sheet using gdata client in python , the sheet exists and I can read it via pandas but gdata is giving 404 error. I have created a working test case to show the issue, contains the URLs to the sheet as well.
import requests
# #Sheet URL:
sheet_url = 'https://docs.google.com/spreadsheets/d/1XFA9PjZySw9CjCoV8N--kNnUpWDnomUmwbXyQenz1AI/edit?usp=sharing'
status = requests.get(sheet_url)
print('Status response code : {}'.format(status))
print('This confirms that the sheet exists')
#print(status.headers)
print('')
try:
from gdata.spreadsheet.service import SpreadsheetsService
key ='1XFA9PjZySw9CjCoV8N--kNnUpWDnomUmwbXyQenz1AI'
client = SpreadsheetsService()
feed = client.GetWorksheetsFeed(key, visibility='public', projection='basic')
for sheet in feed.entry:
print(sheet.title.text)
except Exception as e:
print(e)
print('')
print('G data failed I really do not know why, trying with pandas so show that sheet exists')
import pandas as pd
#Sheet published as csv URL:
pathtoCsv = r'https://docs.google.com/spreadsheets/d/e/2PACX-1vSXJPI2FyxOUr1UsyJ4uXPPIY3HOxaihUmfGbWxH-yXtdu86tBDH2uMxL67UtCKyhjZGpJXzJcm0-1l/pub?gid=0&single=true&output=csv'
df = pd.read_csv(pathtoCsv)
print('')
print('Pandas read:')
print('')
print(df)
You can run this code to see the issue. need to have gdata, requests and pandas.