How to get to end of the worksheet for a very big document?
See original GitHub issueFirst of all, many thanks for writing this awesome library! It has made life so simple for me.
However, at this point I have an issue that I am not sure how to resolve. I have a document that is being updated every minute and therefore it is a quite big document. In order to append a new row every time an update happens, I am using the following code:
all = worksheet.get_all_values()
end_row = len(all) + 1
Here, end_row indicates the row# where I can add my data.
This code works, but the problem with this code is that when the sheet is big, get_all_values() takes a long time to run. The delay starts to add up pretty soon.
So my question is: is there a less time consuming way to get to the end of the document?
P.S. I tried using the row_count property, but that returns 1000 which is of no use because I want to get to the end where I can insert a new row, not the end of the document necessarily.
Issue Analytics
- State:
- Created 9 years ago
- Comments:9 (1 by maintainers)
Top GitHub Comments
Hello @seemantadutta I know I am very late. I have recently started coding in Python and saw this question. The solution to this is print(len(worksheet.get_all_values())) This will give you the length of the list which will be equal to the number of rows in your spreadsheet.
Exactly, you can count non-blank cells within a full column with the Google Sheets core functions:
=COUNTA(A1:A)
This is a simple example that counts non-blank cells, but it also counts empty strings “” .