Search code examples
pythonexcelxlsxlrd

python xlrd string match


I couldnt find anything in the API. Is there a way to return the row number or coordinate of a cell based on a string match? For instance: You give the script a string and it scans through the .xls file and when it finds a cell with the matching string, it returns the coordinate or row number.


Solution

  • for i in range(sheet.nrows):
         row = sheet.row_values(i)
         for j in range(len(row)):
              if row[j] == search_value:
                    return i,j
    return None
    

    something like that... just a basic search