gspread
gspread copied to clipboard
Adding new rows doesn't increase row count property
Environment info
Operating System: MacOS Sierra Python version: 3.6.3 (Miniconda) gspread version: 3.0.0
Steps to reproduce
ws = sheet.worksheet('Sheet1') print(ws.row_count) ws.add_rows(1) print(ws.row_count)
I too am having this issue if anyone can lend a hand
The issue is actually larger than that - the Worksheet
instance seems to never update its properties after changing them, the same goes for self.col_count
and self.title
properties.
I think the issue could be fixed by updating the Worksheet
instance properties every time after calling self.spreadsheet.batch_update()
You're right! Let me know if it would help if I modified the title of this issue to better describe the problem. Or I could close this issue if you want to start a new one.
I tried fixing the issue and opened a pull request, it fixed all the issues for me, let's see if it's viable and we can get this merged into master :)
I'm wondering if there is a resolution to this issue yet?
I tried fixing the issue and opened a pull request, it fixed all the issues for me, let's see if it's viable and we can get this merged into master :)
I would love to see this one merged
Any updates on this? This is a pretty big impediment for us right now.
Can't you just bypass the issue with saving row_count into a variable before appending and then incrementing it everytime you append a row during the code afterwards? Works fine for me at least
Hi this is a bigger issue in fact, as none of the properties are up to date after changing them.
I think the simplest way of solving this for now is to update local properties when an update is successful.
So for instance calling add_rows
will increase the local row_count
value. this can lead to mistakes still because someone could be updating the sheet from an other script or from a web browser. but still it solves the issue for single access.
I have the same problem like issue starter.
Fixed by #1211?
yes closed by #1211
this specific method is fixed, but there is still the same issue if you use other methods such as append_rows
or insert_rows
see https://github.com/burnash/gspread/issues/881#issuecomment-1591337773