1

I've got a spreadsheet URL like this: https://docs.google.com/spreadsheets/d/1231SDFS3afer3SDfsdf-34SDFSDgfdsd42/edit#gid=5439787534

I tried this code I got a reference from https://towardsdatascience.com/read-data-from-google-sheets-into-pandas-without-the-google-sheets-api-5c468536550

googleSheetId = '1231SDFS3afer3SDfsdf-34SDFSDgfdsd42'
worksheetName = 'abcde'

start_url = f"https://docs.google.com/spreadsheets/d/{googleSheetId}/gviz/tq?tqx=out:csv&sheet={worksheetName}"

url = start_url.replace(" ","")

df = pd.read_csv(url)

but I am getting this error

ParserError: Error tokenizing data. C error: Expected 1 fields in line 6, saw 2

How to resolve this without Google API authentication?

6
  • About How to resolve this without Google API authentication?, in your actual situation, is the Spreadsheet not publicly shared? And, you want to retrieve the values from the unshared Spreadsheet without authorization. Is my understanding correct? By the way, are you the owner of Spreadsheet? Commented Oct 26, 2021 at 7:44
  • Yes the original spreadsheet is not publicly shared but I can view it and I want to access it without authentication. I also tried to do the same with the spreadsheet that I own but got the same error Commented Oct 26, 2021 at 13:25
  • Thank you for replying. From I also tried to do the same with the spreadsheet that I own but got the same error, in your actual situation, you want to retrieve the values from a Google Spreadsheet which has other uses and is not publicly shared without the authorization. Is my understanding correct? Commented Oct 26, 2021 at 23:14
  • Yes, that is correct Commented Oct 27, 2021 at 17:06
  • Thank you for replying. Unfortunately, I cannot know the method for retrieving the values from a Google Spreadsheet which has other uses and is not publicly shared without authorization. This is due to my poor skill. I deeply apologize for this. Commented Oct 27, 2021 at 23:22

1 Answer 1

0

The code provided works, with a sheet publicly shared ("Anyone on the Internet with the link can view").

The error you report is a pandas error generated during import, probably because of the shape/content of the data. It is not a google sheets error. Try downloading the data as csv and using read_csv on a local file - I predict you'll get the same error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.