You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Realized that deleting multiple rows one-by-one can take an extremely long time, especially when working with sheets with 1000+ rows, or have e.g. 500+ rows to delete.
I created a function to delete multiple rows by breaking list of row indexes into contiguous ranges and sending a single batchUpdate API call with multiple requests.
e.g.
[1,2,3,4,6,7,9,11,13,14,15]
becomes
[(1:4), (6:7), 9, 11, (13:15)]
i.e. 5 deleteDimension requests instead of 11, and all in 1 function call instead of doing a loop of delete_row(). It has very significantly reduced the time to remove large numbers of rows from sheets in my testing.
It does currently rely on the more_itertools package for the "consecutive_groups()" function, but that functionality could be added internally here if desired, to eliminate the dependency.
The text was updated successfully, but these errors were encountered:
eavalenzuela
changed the title
Feature Suggestion: Multi-row delete function
Feature Suggestion: Multi-row delete function (w/Working implementation)
Aug 30, 2018
eavalenzuela
changed the title
Feature Suggestion: Multi-row delete function (w/Working implementation)
Feature Suggestion: Multi-row delete function (w/working implementation)
Aug 30, 2018
gspread.exceptions.RequestError: (429, '429: <title>Too Many Requests</title
eavalenzuela
changed the title
Feature Suggestion: Multi-row delete function (w/working implementation)
[Feature Suggestion] Multi-row delete function (w/working implementation)
Oct 2, 2018
Realized that deleting multiple rows one-by-one can take an extremely long time, especially when working with sheets with 1000+ rows, or have e.g. 500+ rows to delete.
I created a function to delete multiple rows by breaking list of row indexes into contiguous ranges and sending a single batchUpdate API call with multiple requests.
see delete_rows() function: https://github.com/eavalenzuela/gspread/blob/master/gspread/models.py
e.g.
[1,2,3,4,6,7,9,11,13,14,15]
becomes
[(1:4), (6:7), 9, 11, (13:15)]
i.e. 5 deleteDimension requests instead of 11, and all in 1 function call instead of doing a loop of delete_row(). It has very significantly reduced the time to remove large numbers of rows from sheets in my testing.
It does currently rely on the more_itertools package for the "consecutive_groups()" function, but that functionality could be added internally here if desired, to eliminate the dependency.
The text was updated successfully, but these errors were encountered: