Reputation: 1
I have an Excel file. I need to search only column "A" in the Excel sheet until it matches a text string. When the script finds that match, I would like to see the corresponding cell value. Thanks for your helps in advance!
Upvotes: 0
Views: 354
Reputation: 206
Try using the xlrd library, and iterate through the rows.
import xlrd
filepath = r'C:\Desktop\example.xlsx'
textstring = "foo"
wb = xlrd.openworkbook(filepath)
ws = wb.sheet_by_index(0)
for row in range(ws.nrows):
target = str(ws.cell(row, 0).value)
if target == textstring:
print(target)
print(row)
Upvotes: 1