Mar-29-2021, 08:45 PM
(Mar-29-2021, 07:31 PM)deanhystad Wrote: with open(DIR/'lines_to_look_for.txt', 'r') as file: lines = set([line.strip().split(',')[3] for line in file]) with open(DIR/'check_for_lines.txt', 'r') as file: for line in file: line = line.strip() if line.split(',')[3] in lines: print(f'{line} MATCH') else: print(f'{line} NO MATCH')I appreciate you help but,
I Could not make your doc work.
it produces wrong outcome.
03/28/2021,P,16,LINE1 NO MATCH
03/28/2021,P,6,LINE2 MATCH
03/28/2021,P,9,LINE3 NO MATCH
03/28/2021,P,9,LINE4 MATCH
03/28/2021,P,8,LINE5 NO MATCH
03/28/2021,S,95,LINE6 NO MATCH
03/28/2021,S,1,LINE7 NO MATCH
03/28/2021,P,46,LINE8 NO MATCH
or if I switch file-1 and file-2
03/28/2021,P,6,LINE2 MATCH
03/28/2021,P,9,LINE4 MATCH
I need :
03/28/2021,P,16,LINE1
03/28/2021,P,9,LINE3
03/28/2021,P,8,LINE5
03/28/2021,S,95,LINE6
03/28/2021,S,1,LINE7
03/28/2021,P,46,LINE8