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.

update_cells no longer supports non-contiguous cells (overwrites unlisted cells within the range)

See original GitHub issue

This appears to be a regression in the gpsread use of the v4 API (was previously working: see #177)

Environment info

Operating System: Windows / Linux Python version: 2.7.14 gspread version: 2.1.1

Steps to reproduce

  1. Make a list of cells that are non-contiguous, e.g. [<Cell R7C2 ‘2018’>, <Cell R20C2 ‘2004’>]
  2. Call update_cells, passing the list
  3. Cells R7C2 through R20C2 inclusive get updated, with only R7C2 and R20C2 having values, R8-R19C2 all get zeroed out.

Stack trace or other output that would be helpful

Compare update_cells implementation in /v4/models.py with models.py

>>> worksheet.range('B7:B20')
[<Cell R7C2 ''>, <Cell R8C2 ''>, <Cell R9C2 u'2013'>, <Cell R10C2 u'2013'>, <Cell R11C2 u'2015'>, <Cell R12C2 u'2015'>, <Cell R13C2 ''>, <Cell R14C2 u'2017'>, <Cell R15C2 u'2015'>, <Cell R16C2 u'2017'>, <Cell R17C2 u'2016'>, <Cell R18C2 u'2014'>, <Cell R19C2 u'2012'>, <Cell R20C2 ''>]
>>> cells = worksheet.range('B7:B20')
>>> other_cells = []
>>> other_cells.append(cells[0])
>>> other_cells.append(cells[len(cells)-1])
>>> other_cells
[<Cell R7C2 ''>, <Cell R20C2 ''>]
>>> other_cells[0].value = "test"
>>> other_cells[1].value = "testing"
>>> len(other_cells)
2
>>> worksheet.update_cells(other_cells)
{u'spreadsheetId': u'**removed**', u'updatedRange': u'Collection!B7:B20', u'updatedCells': 14, u'updatedRows': 14, u'updatedColumns': 1}
>>> worksheet.range('B7:B20')
[<Cell R7C2 u'test'>, <Cell R8C2 ''>, <Cell R9C2 ''>, <Cell R10C2 ''>, <Cell R11C2 ''>, <Cell R12C2 ''>, <Cell R13C2 ''>, <Cell R14C2 ''>, <Cell R15C2 ''>, <Cell R16C2 ''>, <Cell R17C2 ''>, <Cell R18C2 ''>, <Cell R19C2 ''>, <Cell R20C2 u'testing'>]

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
burnashcommented, Jun 30, 2018

@CianH thank you for reporting the issue. It was fixed in #553 and released in version 3.0.1 on pypi. Please upgrade the library and check.

@AlexRiina thank you very much for the hint and comments. @ADraginda thank you again for the pull request with the fix.

I’m closing this issue now.

1reaction
ADragindacommented, May 21, 2018

@CianH Using @AlexRiina 's suggestion, I verified that setting to None does work. I’ll be submitting a PR, but in the interim you can workaround the issue by setting the .value for every cell to None before doing your actual value setting. If you do that, then only your changes will be applies.

Read more comments on GitHub >

github_iconTop Results From Across the Web

google sheets api select non-adjacent cells - Stack Overflow
What would be the range for selecting multiple non-adjacent cells? I am trying to update cells that are non-adjacent from a sheet (A2...
Read more >
How To Select Non Adjacent Cells In Excel & Google Sheets
Click on the cell. Press the Control key on the keyboard. Keep holding it down while you are selecting cells.
Read more >
2-7: Select Non-Contiguous (Non-Adjacent) Cell Ranges
Non-contiguous ( non adjacent ) cell ranges are blocks of cells that are not next to each other. You'll learn how to select...
Read more >
How to Select Non-contiguous Ranges of Cells in Excel 2016
You can select different ranges of cells in two ways, ... You can change the formatting for all non-contiguous cells selected at the...
Read more >
Fit to Element Range Dialog - Bentley - Product Documentation
Lets you type a cell name or regular expression to identify one or more cells. This limits the search for specified elements to...
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