I am using linecache to get the lines before the occurrence of a string. But it is not working. I cannot understand what the problem is?
with open(fileName, 'r') as inFile:
between = False
for num, line in enumerate(inFile, 1):
if st_time in line:
between = True
if between:
if 'Broken pipe' in line:
line1 = linecache.getline(fileName, num-55)
if 'ERROR' in line1:
print("yes")
if en_time in line:
between = False