Search code examples
pythongoogle-sheetsgspreadpygsheets

How to search thru Google Spread Sheet


I'm trying to find a value exist in the GSheet. Connection to Google sheet works. I can fetch all the worksheets within the files, but I can't some reason iterable the list of worksheets. Here is the file looks likes: enter image description here I'm trying to find cell value and then fetch the values within that column.

Sample Code:

#Gsheet setup w/ key.json token
scope = ['https://www.googleapis.com/auth/drive.file','https://www.googleapis.com/auth/spreadsheets','https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('gdoc.json',scope)
gc = gspread.authorize(credentials
sheet = gc.open("GSHEET_Search_test")
cell = sheet.find("B02")
print(cell)

Getting errors:


Solution

  • I was able to iterate over the worksheet index value worksheet = sheet.get_worksheet(counter)