Dec-11-2020, 01:51 AM
I finallyI figured out where to move the:
if count > 0: print(f"{cur_ef}: {e_el} - {count}")And now it almost does what I need, it prints:
1001x03 - 2 1001x03 - 2It should print :
100x02- 2 1001x03 - 2
import os list = ['100x02','1001x03'] # list of errors# path = 'C:\\02' for root,dirs, files in os.walk(path): for ef in files : cur_ef = os.path.join(path,ef) if os.path.isfile(cur_ef): with open (cur_ef,'r') as fto_read : count = 0 for e_ln in fto_read : # reading each line from a file # e_ln=e_ln.rstrip() #print (e_ln) for e_el in list : # reading an element from the list # if e_el in e_ln : e_el=e_el.rstrip() #print ("FOUND LINE --->> ",e_ln) count+=1 if count > 0: print(f"{e_el} - {count}")