简体   繁体   中英

I want to fetch a single row for a value from google sheets - gspread

import gspread

list_of_dicts = worksheet.get_all_records()
for d in list_of_dicts:
    d['Name'] == "Dash"

In excel sheet, I have Name, Age, address. I want to be able to fetch the whole row for a particular value. The only way I could figure from documentation is this. But I do not know how to fetch the row number

values_list = worksheet.row_values(1)

How do I find the index?

From the documentation it looks like you can query for a string and you get back the cell of the value. Then you can get the row of the cell and fetch the whole row.

So for your example you can query for the name you want

cell = worksheet.find("Dash")

And then ask for the whole row where the name is Dash

values_list = worksheet.row_values(cell.row)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM