When using Python OpenPyxl, how would I iterate through each Column (in only one row) to find a value?
Here's my current (failing) attempt -- (There appears to be an error in (at least) my 2nd for loop.)
ps: Xposted elsewhere last week, but no working answers yet. I'll post the answer to both forums once found.
Thanks so much in advance,
CG
Here's my current (failing) attempt -- (There appears to be an error in (at least) my 2nd for loop.)
1 2 3 4 5 |
book = openpyxl.load_workbook(excelFile) for sheet in book.worksheets: #For each worksheet for colidx in sheet.iter_cols(sheet.min_col,sheet.max_col): #For each Column in a worksheet if sheet.cell( 1 ,colidx).value = = "ValueImLookingFor" : #Search each Column in only Row #1 for value print ( "Found ValueImLookingFor in COLUMN " + colidx) |
Thanks so much in advance,
CG