question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

get_all_records() returns error

See original GitHub issue

When using get_all_records or get_all_values, the api errors with the following error:

gspread.exceptions.APIError: { "error": { "code": 400, "message": "Range ('DF1'!DF1) exceeds grid limits. Max rows: 10, max columns: 12", "status": "INVALID_ARGUMENT" }

I’m also unable to use sheet.row_count and sheet.col_count in combination with sheet.range() to get the entire sheet data.

code:

scope = ['https://spreadsheets.google.com/feeds']
credentials = ServiceAccountCredentials.from_json_keyfile_name(
           'xxx-25a413f7fcd6.json', scope)
gc = gspread.authorize(credentials)
wks = gc.open(sheet)
sheet = wks.worksheet(worksheet)
sheetData = sheet.get_all_records()

Stack trace or other output that would be helpful


  File "C:/Users/xx/Documents/Python/doubleclick scraping/gspread_grabber.py", line 118, in read_gs
    sheetData = sheet.get_all_records()
  File "C:\Users\xx\AppData\Local\Programs\Python\Python36\lib\site-packages\gspread\models.py", line 470, in get_all_records
    data = self.get_all_values()
  File "C:\Users\xx\AppData\Local\Programs\Python\Python36\lib\site-packages\gspread\models.py", line 444, in get_all_values
    data = self.spreadsheet.values_get(self.title)
  File "C:\Users\xx\AppData\Local\Programs\Python\Python36\lib\site-packages\gspread\models.py", line 110, in values_get
    r = self.client.request('get', url, params=params)
  File "C:\Users\xx\AppData\Local\Programs\Python\Python36\lib\site-packages\gspread\client.py", line 79, in request
    raise APIError(response)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dbarrellcommented, Nov 18, 2019

Hi @mritzco,

Just came across this issue again and saw your reply - yes that works for me also. A PR would be great!

1reaction
XiaoMuttcommented, Jul 13, 2018

@burnash @ChamRoshi I think this is what happened: gspread does not single quote the sheetname when requesting the values. When you use a sheetname like DF1, stupid Google API will treat it as a range (here is the cell DF1 which usually does not exist), and looks the first sheet to find that cell.

I tested this by adding single quotes around the sheet name and it worked.

In the documentation: https://developers.google.com/sheets/api/guides/concepts#a1_notation:

If the sheet name has spaces or starts with a bracket, surround the sheet name with single quotes ('), e.g ‘Sheet One’!A1:B2. For simplicity, it is safe to always surround the sheet name with single quotes.

@burnash could confirm and fix this ASAP?

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL returns the error message "Cannot query field ...
GraphQL returns the error message "Cannot query field..." when I try to get all records ; 'query' => [ 'product' ; 'products' =>...
Read more >
ThingWorx 8 Part 2 Error: Unable to Invoke Service...
"Error Executing Service, Unable to Invoke Service GetAllRecords on ACMESQLDatabase : null" ... connectionValidationString = SELECT NOW().
Read more >
Return codes - IBM
CIM return code Description Method 0 Success GetFreeExtends() ListConfiguration. Backups() 0 Success AddNode() 0 Success CheckValidity()
Read more >
How to handle ORA-01422 exact fetch returns more - Ask TOM
All of a sudden, when I try to insert values, then I got this Error. ORA-01422: exact fetch returns more than requested number...
Read more >
Query | GORM - GORM
... when querying the database, and it will return the error ErrR. ... in the relevant field name or the dbname to Where()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found