Excel's column A has many rows with different values. Example:
613
613
613
625
625
631
631...etc
I want to iterate through column A and when the cell's value refers to a new value, obtain the cell's row.
Expected result example: When the cell's value changed to 625, it will return the row 4. When 631, 6, and so on.
This is my code so far:
from openpyxl import Workbook, load_workbook
wb = load_workbook("Workbook.xlsx")
ws = wb.active
sheet = wb["Visual Query2"]
for row in ws.iter_rows(min_row=1, max_col=1, max_row=223181):
for cell in row::
print(cell.row)
I got a bit lost when trying to catch when the cell starts having a different value. If someone can provide me guidance, I will really appreciate it. Thanks.
Edit: Was able to find a temporary solution utilizing:
wb = load_workbook("Workbook.xlsx")
ws = wb.active
sheet = wb["Sheet"]
for fila in ws.iter_rows('A2:A7'):
for celda in fila:
if celda.value != celda.offset(-1, 0).value:
print(celda.row)