Apr-23-2020, 05:43 PM
To deanhystad,
Thanks for the snippet!
I appreciate your help, you the only one trying to help.
I replaced my code with yours and it now prints only one line ( not even ones I'm looking for)
I really do not understand how just one "lstart" will find a pair and it doesn't.
what do I do wrong?
Thanks for the snippet!
I appreciate your help, you the only one trying to help.
I replaced my code with yours and it now prints only one line ( not even ones I'm looking for)
I really do not understand how just one "lstart" will find a pair and it doesn't.
if lstart in line: # Did I find a pair? if last_lstart is not None and last_lstr is not None: # I found a pair!I replaced my part of the code with yours and it finds a line that not even the one I'm looking for.
what do I do wrong?
f_toread = 'C:\\02\mytext.txt' lstr = '-- InitializeRequest' lstart = "LotComplete" last_lstart = None last_lstr = None with open(f_toread) as fp: line = fp.readline() print (line) cnt = 1 flag = False while line: if lstart in line: # Did I find a pair? if last_lstart is not None and last_lstr is not None: # I found a pair! last_lstart = cnt last_lstr = None elif lstr in line: last_lstr = cnt cnt += 1 line = fp.readline()