The Python API for Google sheets has a get
method to get values from a spreadsheet, but it requires a range
argument. I.e., your code must be something like this,
sheets_service = service.spreadsheets().values()
data = sheets_service.get(spreadsheetId = _GS_ID, range = _SHEET_NAME).execute()
and you cannot omit the range
argument, nor will a value of ''
work, or a value of 'Sheet1'
or similar (unless there is a sheet named Sheet1
).
What if I do not know the sheet name ahead of time? Can I reference the first or left-most sheet somehow? Failing that, is there a way to get a list of all the sheets? I have been looking at the API and have not found anything for that purpose, but this seems like such a basic need that I feel I'm missing something obvious.
service.spreadsheets().get(spreadsheetId=_GS_ID).execute()
? The document is here. In this case, it is required to know the Spreadsheet ID. – Tanaikeget
method onspreadsheets()
too. That method returns different information. Thanks for your reply. BTW, if you'd like to write this up as an answer instead of a comment, I'd be happy to upvote & check it off as the answer. – mhuckarange="A:Z"
would bring back columnsA-Z
from the first sheet. Reference: developers.google.com/sheets/api/guides/concepts#a1_notation – AChampion