Aug-06-2022, 02:42 AM
Hi all,
I want to sort csv file find which item was failed(if this column have limit)and paint color for the cell, delete afterward item such as final data.xlsx format. I only know how to sort failed and don't know how to compared limit, kindly help me for the matter, thanks!!
I want to sort csv file find which item was failed(if this column have limit)and paint color for the cell, delete afterward item such as final data.xlsx format. I only know how to sort failed and don't know how to compared limit, kindly help me for the matter, thanks!!
import csv array=[] failed=[] count=0 with open('Log.csv','r') as fp: csv_reader=csv.reader(fp) header = next(csv_reader) listreport=list(csv_reader) for line in listreport: if count<3: array.append(line) if line[5]=='Failed': failed.append(line) count+=1 with open('new_name.csv','w',encoding='utf-8',newline='') as new_line: csv_writer=csv.writer(new_line) csv_writer.writerow(header) csv_writer.writerows(array) csv_writer.writerows(failed)