Mar-29-2021, 09:27 PM
(Mar-29-2021, 11:27 AM)Serafim Wrote: with open ('file_2','r') as l_few : f2=l_few.readlines()sp23 = [s.split(',')[3].strip() for s in f2] # collect all the terms you need to comparewith open ('file_1','r') as f1: for lf1 in f1: lf1=lf1.strip() sp1 = lf1.split(",") if sp1[3] in sp23: pass # here we have a match so print nothing # spL2=lf2.split(",") #print (" File 2 Line matched --> "+lf2) #break else : print (lf1) # print the non-matching line #break
My bad! the code s actually working!
Thank you very much for your help!
I made some insignificant changes to your code, just easier to read (for me).
with open (file_1,'r') as l_few : f1=l_few.readlines() for s in f1 : sp23 = s.split(',') with open (file_2,'r') as f2: for lf2 in f2: lf2=lf2.strip() sp2 = lf2.split(",") if sp2[3] in sp23: pass # here we have a match so print nothing else : print (lf2) # print the non-matching line #break