Dec-11-2020, 07:07 PM
Bowlofred! You pushed me in the right direction!
I think I fixed my script and it does what I want now.
It finds all the 'error codes' from the list in all my log files and prints them out in the format I want:
Thank you again for all your help!
I really appreciate it, you guys make my life easier.
I think I fixed my script and it does what I want now.
It finds all the 'error codes' from the list in all my log files and prints them out in the format I want:
3-100x02 2-1001x03Here is a final version of the snippet:
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 er_nm = [] for e_ln in fto_read : # reading each line from a file # for e_el in list : # reading an element from the list # if e_el in e_ln : e_el=e_el.rstrip() er_nm.append(e_el) count+=1 if count > 0: print ("Number of Errors - Name ---- >> ",str(count)+'-'+er_nm[0])
Thank you again for all your help!
I really appreciate it, you guys make my life easier.