I have an algorithm that finds a value in a cell, for this case lets say that cell is C10. I need to look next to that in column D for a value, and if that value doesnt match what i need, to go up one cell from that and check for a match, etc. I have this so far:
bits = []
for row in ws.iter_rows(row_offset=4,column_offset=3):
#skip over empty rows
if row:
#current cell is in column C
cell = row[2]
try:
#find the lowest address in the excel sheet
if cell.internal_value == min(address):
#somehow match up in column d
for '''loop and search col D''':
if str(row[3].internal_value).upper == ('CONTROL 1' or 'CON 1'):
#add bits
for cell in row[4:]:
bits.append(cell.internal_value)
#pass over cells that aren't a number, ie values that will never match an address
except ValueError:
pass
except TypeError:
pass
Is there a way to do this? I know the comparison using row[3] compares in column D, but if it isnt correct the first time, i dont know how to go up the column. Or in other words, changing the value in row[value] moves around the row, and I need to know what value/how to move around the column.
Thanks!
1 Answer