Reputation: 13
I am trying to search a sheet using openpyxl and then remove the entire row when a value is found. When I attempt the below code I am receiving TypeError: '>' not supported between instances of 'tuple' and 'int' Can someone advise how I can iterate on a cell but then reference the row from the parent loop?
Here is my code:
wb = xl.load_workbook(filename)
sheet = wb[os.path.splitext(filename)[0]]
for row in sheet.rows:
for cell in row:
if cell.value == "Report Generated By :":
sheet.delete_rows(row, 1)
Upvotes: 0
Views: 1388
Reputation: 13
After reading up on this article: https://openpyxl.readthedocs.io/en/stable/api/openpyxl.cell.cell.html
I discovered I could solve this with the following statement:
sheet.delete_rows(cell.row, 1)
Upvotes: 1