How to delete/remove row from the google spreadsheet using gspread lib. in python?

Chintan picture Chintan · Jan 31, 2013 · Viewed 10.5k times · Source

I want to delete a record from a google spreadsheet using the gspread library.

Also, how to can I get the number of rows/records in google spreadsheet? gspread provides .row_count(), which returns the total number of rows, including those that are blank, but I only want to count rows which have data.

Answer

Burnash picture Burnash · Dec 14, 2016

Since gspread version 0.5.0 (December 2016) you can remove a row with delete_row().

For example, to delete a row with index 42, you do:

worksheet.delete_row(42)