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.

append_row INVALID_ARGUMENT when appending more than one item at a time

See original GitHub issue

Hi! 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

  1. Create a worksheet with a name containing the colon character :
  2. Get your pointer to the worksheet, e.g. ws
  3. 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:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:9

github_iconTop GitHub Comments

1reaction
lavigne958commented, Jun 8, 2022

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. the spreadsheet and worksheet object have dedicated methods for all operations. All methods will use the function utils.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).

1reaction
lavigne958commented, May 19, 2021

This has been fixed. Tried to append a row to a sheet containing a semicolon : in its name and it works.

Closing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Appending multiple rows to Spreadsheet - Google Apps Script
Simple Example: var sheet= SpreadsheetApp.openById(ssId).getSheetByName(sheetName); sheet.appendRow([ ...
Read more >
OpenSim::DataTable_< ETX, ETY > Class Template Reference
The function appendRow() is pretty flexible and it is possible to append a row with ... InvalidArgument, If the input file contains more...
Read more >
Class Sheet | Apps Script - Google Developers
Adds developer metadata with the specified key, value, and visibility to the sheet. appendRow(rowContents), Sheet, Appends a row to the bottom ...
Read more >
Write multiple rows of data to Google Sheets using Apps Script
Method 1: Append a single row at a time to a Google Sheets spreadsheet using Apps Script (Not recommended ). In the code...
Read more >
Make email more actionable with Google Workspace Add-ons
In this codelab, you'll design and implement a Gmail add-on that allows users to easily add expenses from receipts into a Google Sheet ......
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