Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sheet reference gets ducked typed to cell reference #560

Open
pungys opened this issue Nov 18, 2022 · 0 comments
Open

Sheet reference gets ducked typed to cell reference #560

pungys opened this issue Nov 18, 2022 · 0 comments
Labels

Comments

@pungys
Copy link

pungys commented Nov 18, 2022

I encountered an issue when trying to call get_all_values() on a sheet that is a valid cell reference - such as A1(exists) or OT1(doesn't exist).

Describe the bug
Whenever I try to read data from a sheet called OT1 I get a 400 error - Range ('OT1'!OT1). This seems to be related to this google sheet bug. Apparently, the sheet name is also duck typed to a cell reference (which may not exist) and it returns 400 error. If the cell exists (such as A1) this call passes but returns unexpected results - only the contents of cell A1 in sheet A1.

Current solution
Explicitly define cell range. I replaced get_all_values() with get_values() with large enough column span.

To Reproduce
Create a worksheet with a sheet called 'OT1' then try to get_all_values().

  File "/venv/lib/python3.10/site-packages/pygsheets/worksheet.py", line 492, in get_all_values
    return self.get_values(None, None, returnas=returnas, majdim=majdim,
  File "/venv/lib/python3.10/site-packages/pygsheets/utils.py", line 180, in wrapper
    return method(self, *args, **kwargs)
  File "/venv/lib/python3.10/site-packages/pygsheets/worksheet.py", line 354, in get_values
    values = self.client.get_range(self.spreadsheet.id, grange.label, majdim,
  File "/venv/lib/python3.10/site-packages/pygsheets/client.py", line 234, in get_range
    result = self.sheet.values_get(spreadsheet_id, value_range, major_dimension, value_render_option,
  File "/venv/lib/python3.10/site-packages/pygsheets/sheet.py", line 419, in values_get
    return self._execute_requests(request)
  File "/venv/lib/python3.10/site-packages/pygsheets/sheet.py", line 495, in _execute_requests
    response = request.execute(num_retries=self.retries)
  File "/venv/lib/python3.10/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/venv/lib/python3.10/site-packages/googleapiclient/http.py", line 915, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://sheets.googleapis.com/v4/spreadsheets/some-valid-id/values/OT1?majorDimension=ROWS&valueRenderOption=FORMATTED_VALUE&dateTimeRenderOption=SERIAL_NUMBER&alt=json returned "Range ('OT1'!OT1) exceeds grid limits. Max rows: 4999, max columns: 27". Details: "Range ('OT1'!OT1) exceeds grid limits. Max rows: 4999, max columns: 27">

System Information

  • OS: MacOS 12.2.1
  • pygsheets version : 2.0.5
  • pygsheets installed from (github or pypi): pypi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants