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.

Appending rows with empty cells results in increasing row indentation

See original GitHub issue

Environment info

Operating System: Windows 10 Python version: 3.6.3 (Anaconda) gspread version: both 2.0.0 and 2.1.1

Steps to reproduce

ws = sheet.worksheet('Sheet1')
ws.append_row(['Test1', '', 'Test2'])
ws.append_row(['Test1', '', 'Test2'])
ws.append_row(['Test1', '', 'Test2'])

Output

image

It looks like new rows appended with append_row() start from the last populated column on the previous rows. This is a relatively new behaviour that started a day or so ago.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

6reactions
burnashcommented, Feb 15, 2020

It looks like this is not a bug. I tried to run append_row() with different table layouts and it appears that the row shift happens when the Sheets API has multiple logical “tables” to chose from and it selects the rightmost. It’s explained in details in the example in the Sheets API guide here: https://developers.google.com/sheets/api/guides/values#appending_values

So In this particular case, when appending the second row the Sheets API sees two logical “tables” A1 and C1 and decides to append to C1:

example

When appending the third the same happens with E2 and so on.

As the Sheets API guide suggests the solution is to explicitly tell the Sheets API which table it needs to append to. For that, we’ll need to pass an explicit range parameter to the API call. I’ve implemented this in #726 (and named the parameter table_range).

So for this particular case, after #726 is merged you’ll need to call append_row this way:

ws.append_row(['Test1', '', 'Test2'], table_range='A1')

That way the API will know that you’d like to append to the table that starts with A1 cell. Again, this is only need in the case where there’s ambiguity in the selection of logical “tables”.

0reactions
JeffJasskycommented, Jan 13, 2020

… Still happening.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Insert a Blank Row after Every Row in Excel (or Every Nth Row)
In this tutorial, I will show you some really simple ways to insert a blank row after every row in the existing dataset...
Read more >
Adjust indents and spacing - Microsoft Support
Use Paragraph settings to change indentation, line spacing, and alignment.
Read more >
Please help....bold row based on indent - Mr. Excel
Please help write a macro that will bold entire rows based on no indentation.
Read more >
How to change alignment in Excel, justify, distribute and fill cells
In Microsoft Excel, the Tab key does not indent text in a cell like it does, say, in Microsoft Word; it just moves...
Read more >
Excel table not formatting new rows appropriately - Super User
To resolve this click on the header of a column then right click and choose "Format Cells" option and set the desired format....
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