I am trying to find an item inside a worksheet using gspread but only for a specific column. For some reason, when I do
ws.find(item, in_column = 6)
it givens an
IndexError: list index out of range
but when I do it with 2, it works fine. I tested it, and for any column 5 and over, it does not work. Anyone know why this is? I can send the full error message and code if needed.
When I tested all sheets in your sample Spreadsheet using ws.find(item, in_column = 6)
, I confirmed that an error occurred on the 1st sheet ("Info" sheet). Also, I confirmed that in your 1st sheet of "Info", the merged cells are existing. In this case, it seems that such an error occurs.
If you are not required to use ws.find(item, in_column = 6)
in the 1st sheet, as a simple modification, how about the following modification?
cell = None
wslist = hoards.worksheets()
for ws in wslist:
if ws.title != "Info":
cell = ws.find(knife, in_column=6)
if (cell != None):
worksheet = ws
print("found cell")
break
cell = None
wslist = hoards.worksheets()
for i, ws in enumerate(wslist):
if i > 0:
cell = ws.find(knife, in_column=6)
if (cell != None):
worksheet = ws
print("found cell")
break