'How to parse lines after a certain text in python
I am trying to parse a text file. I need certain line of it only. I need to search for "tool> exit" and parse all lines after that until 2nd last line. Here is the text I am trying to parse -
complete
line:567 finish;
tool> exit
Finish Failed Myname
0 0 ABC_dog_ctl
5 1 ABC_cator_t
34 0 ABC_cator_t
0 0 ABC_cator_t
Total = 12, Failing = 4
summary at 70s
TOOL: mytool
I am trying to parse only -
Finish Failed Myname
0 0 ABC_dog_ctl
5 1 ABC_cator_t
34 0 ABC_cator_t
0 0 ABC_cator_t
Total = 12, Failing = 4
summary at 70s
I am trying something like -
my_list = []
for line_no, line in enumerate(Infile):
if "tool> exit" in line:
start_line = line_no
my_list.append[line+1]
But I am not getting desired result. There are multiple instances of "TOOL" so I can't search it, but it's the last line so I think I can look for line above it always.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
