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.

How to get to end of the worksheet for a very big document?

See original GitHub issue

First 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:closed
  • Created 9 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
WolfClaw009commented, May 13, 2020

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.

0reactions
JoeCharlieHcommented, Jun 9, 2020

Create that new row in other worksheet, Which take no time and keep doing it for few entries and after that insert that worksheet data into your final sheet, like a batch process.

This will help to save time as code doesn’t have to initialize all the data.

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 “” .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Finding the End of the Worksheet - Microsoft Excel Tips
Want a quick way to get to the last cell in your worksheet? ... you press Ctrl+End, Excel takes you to the bottom...
Read more >
Excel file size out of control? Learn how to reduce Excel ...
CTRL + DOWN ARROW, Go to the last row that has data in it. ; CTRL + RIGHT ARROW, Go to the last...
Read more >
Locate and reset the last cell on a worksheet - Microsoft Support
To locate the last cell that contains data or formatting, click anywhere in the worksheet, and then press CTRL+END. Note: To select the...
Read more >
Excel Ctrl End goes too far - Microsoft Office Courses
Ctrl + End is the shortcut key that takes you to the very end of your worksheet. However, Ctrl + End can be...
Read more >
Reduce the file size of your Excel workbook - YouTube
Have you ever had a large Excel file that you know should be significantly smaller? There are a couple of tricks to reducing...
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