Is there a way in Python to compare Excel cells in different rows, and if the cells are different, insert a row? Here is what I have so far for my python code:
filename2 = "myfile.xlsx." wb2 = xl.load_workbook(filename2) ws2 = wb2.active mr2 = ws2.max_row #here is where I compare the cells and insert a row if it does not match for i in range(2, mr + 1): if ws2.cell(row=i, column=2).value != ws2.cell(row=i + 1, column=2).value: ws2.insert_rows(idx= i + 1) wb2.save(str(filename2))
1.4m articles
1.4m replys
5 comments
56.9k users