In each row, I want to filter for the value "TRUE" in column 8. If that row contains "TRUE" in that column, I want to copy that row to another sheet. Is there a way to do this using openpyxl?
#Filter for rows containing TRUE
from openpyxl import Workbook
from openpyxl import load_workbook
import glob
wb1 = openpyxl.load_workbook('DataSource.xlsx') #Source
wb2 = openpyxl.load_workbook('DataTarget.xlsx') #Target
# Refrence the workbook to the worksheets
sh1 = wb1["sheet 1"] #Source
sh2 = wb2["sheet 2"] #Target
min_col, min_row, max_col, max_row = range_boundaries("A:I")
for row in sh1.iter_rows():
if row[8].value == "TRUE":
sh2.append((cell.value for cell in row[min_col-1:max_col]))
wb2.save("Filter Test.xlsx")