I am trying to write a script that will delete rows based on whether or not the row's corresponding cell value in the first column contains a specific character, in this case a '#'.
I have tried writing the following function that would hopefully iterate through the sheet and return a new sheet with the deleted rows. LabSample is the sheet that I am working in.
def remove_headers():
for rowNum in range(2, LabSample.max_row):
sys_sample_code = LabSample.cell(row=rowNum, column=1).value
if '#' not in sys_sample_code:
continue
else:
LabSample.delete_rows(rowNum, 1)
return LabSample
for row in LabSample.rows:
print(row[0].value)
I currently am not getting any error messages, but the output I am getting is unchanged from the input. It appears that no rows have been deleted.