append_row INVALID_ARGUMENT when appending more than one item at a time
See original GitHub issueHi! I found an error when you append_row to a worksheet with a list with length > 1, IF the worksheet has a name with a colon :
in it - other characters could cause this too, haven’t tested comprehensively. I think this might be because gspread only expects one colon - as part of the error message, I got Requested writing within range [':'!A3], but tried writing to column [B]
, even though I requested writing to a range larger than the one denoted. Or it might be because in order to denote a range, sheet name and colons are used in conjunction (e.g. somesheet!A1:C1
), but when a colon is used, special formatting must be used (e.g. '0:00'!A1:C1
), and this messes with gspread’s parsing. Or something else.
Environment info
Operating System: macOS 10.13.2 Python version: 3.6.5 gspread version: 3.0.0
Steps to reproduce
- Create a worksheet with a name containing the colon character
:
- Get your pointer to the worksheet, e.g.
ws
- Run
ws.append_row(['some', 'values'])
Stack trace or other output that would be helpful
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/owner/anaconda/lib/python3.6/site-packages/gspread/models.py", line 702, in append_row
return self.spreadsheet.values_append(self.title, params, body)
File "/Users/owner/anaconda/lib/python3.6/site-packages/gspread/models.py", line 100, in values_append
r = self.client.request('post', url, params=params, json=body)
File "/Users/owner/anaconda/lib/python3.6/site-packages/gspread/client.py", line 79, in request
raise APIError(response)
gspread.exceptions.APIError: {
"error": {
"code": 400,
"message": "Requested writing within range [':'!A3], but tried writing to column [B]",
"status": "INVALID_ARGUMENT"
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:9
Top GitHub Comments
Hi, yes it is, but this is not a bug, because the method
spreadsheet.values_update
is not intended to be used directly by a user. thespreadsheet
andworksheet
object have dedicated methods for all operations. All methods will use the functionutils.absolute_range_name
that will prevent this issue.If someone needs/wants to use directly the method, then they must cover the range name themselves (like other method do, using
utils.absolute_range_name
function).This has been fixed. Tried to append a row to a sheet containing a semicolon
:
in its name and it works.Closing this issue.