Dec-07-2019, 01:05 PM
Hi,
I am comparing two Excell files, and if a cell from file1 != a cell in file2 print that, and highlight the cell different in file2 (with red font).
I am comparing two Excell files, and if a cell from file1 != a cell in file2 print that, and highlight the cell different in file2 (with red font).
Name Age AAA 25 BBB 12 CCC 42 Name Age AAA 25 BBB 16 ACC 3I use below code, I can print the rows differently, but how can I highlight the cell which is different in file2.
file1_name = "D:InputCSV1.csv" file2_name = "D:\InputCSV2.csv" f1= open(file1_name, 'r') f2= open(file2_name, 'r') f1_lines = f1.readlines() f2_lines = f2.readlines() for k,l in enumerate(f1_lines): if(f1_lines[k] in f2_lines): pass else: print("INFO: " + f1_lines[k][:-1] +"::"+ f1_lines[k][:-1] + " ->mismatch"