Apr-19-2020, 06:26 PM
I'mproccesing a text file, searching for lines and printing those to an OutPut file.
Code has 4 'IF' blocks,
If I call "print" after "IF block" 3 it prints my "found lines"
If I call "print" after "IF block" 4 print returns empty lines.
The script actually sees Var from "IF block" 4 and evet prints it to an OutPut file but nothing from the 3 "IF blocks" above.
I'm new to Python
and it seems strange to me, no errors and no "print".
Thank you!
Code here:
Code has 4 'IF' blocks,
If I call "print" after "IF block" 3 it prints my "found lines"
If I call "print" after "IF block" 4 print returns empty lines.
The script actually sees Var from "IF block" 4 and evet prints it to an OutPut file but nothing from the 3 "IF blocks" above.
I'm new to Python

Thank you!
Code here:
import os import re runtime_l = '," Run Time' start_tm = '," Start Time' end_tm = '," End Time' program_n = '," Test Program Name:' st_t1 = '' endt1 = '' rnt_1 = '' ftow = open('C:\\01\\sorted_OUT.txt','w') with open('C:\\02\\en15\\TST2\\Debug_1.log','r') as ftor: for ln in ftor: #print (ln) ln = ln.rstrip() if start_tm in ln: *extraWords,st_t1 = ln.split('Time') # Grtting Start Time line # st_t1=st_t1.replace('"','') #print ("Start Time Line -->> " , str_t) #print (type(st_t1)) if end_tm in ln: #print (ln) *extraWords,endt1 = ln.split('Time') # Grtting END Time line # endt1=endt1.replace('"','') #print ("ENd Time line -->> " , endt1) if runtime_l in ln: #print (ln) *extraWords,rnt_1 = ln.split('Time') # Grtting Run Time line # rnt_1=rnt_1.replace('"','') #ftow.write (str_t+ endt_p+ rnt_p +'\n') # works here# if program_n in ln : #print ("Start Time Line -->> " , str_t1) *extraWords,prg_n = ln.split('Name') # Grtting program name line # prg_n=prg_n.replace('"','') #print ("Program Name -->> " ,prg_n) ftow.write (st_t1 +endt1 + rnt_1 + prg_n + '\n') print ("All Lines -->> "+st_t1 +endt1 + rnt_1 + prg_n + '\n') # does not work ftow.close()