nithinmurali / pygsheets

Google Sheets Python API v4
https://pygsheets.readthedocs.io/en/latest
Other
1.51k stars 220 forks source link

Is there a function to GET the last used row & column in the wks? #578

Closed sneakerush closed 1 year ago

sneakerush commented 1 year ago

As the title states, how can i GET the last used row and column in the worksheet? Edit: Without reading all the data and being resource intensive

felipemaion commented 1 year ago

Converting to dataframe is too resource intensive?

wks.get_as_df().iloc[-1,-1]

Other option would be the worksheet having the same size of the data used. And than getting wks.rows and wks.cols numbers, and get the value at this point.

nithinmurali commented 1 year ago

Both of the above options would work. Unfortunately there is no sheets API for this. YOu can use the append_table as a workaround for this though.

Call the append_table with values=[], In the requests it would return details of the last row and column.

https://pygsheets.readthedocs.io/en/stable/worksheet.html#pygsheets.Worksheet.append_table