Hi,
I have a file with below sample entries.
2282:depth=3 hl=4 l=12096 cons: start_indi
2286:depth=4 hl=4 l=5321 cons: next
2290:depth=5 hl=4 l=4785 cons: next
2294:depth=6 hl=2 l= 1 base: type :01
i want to achieve the following.
I start reading my entries when i get my predefined indicator **start_indi**
I would like to get the output as **[2286:5321]**, but i am getting it as **[2286:5321 cons: next]**
also i want to continue extracting the
prev_offset + prev_length = next_offset
so in my file the next_offset will be at some random point i will read based on that condition.
please help
below is my code:
I have a file with below sample entries.
2282:depth=3 hl=4 l=12096 cons: start_indi
2286:depth=4 hl=4 l=5321 cons: next
2290:depth=5 hl=4 l=4785 cons: next
2294:depth=6 hl=2 l= 1 base: type :01
i want to achieve the following.
I start reading my entries when i get my predefined indicator **start_indi**
I would like to get the output as **[2286:5321]**, but i am getting it as **[2286:5321 cons: next]**
also i want to continue extracting the
offsets
and lengths
as long as they satisfy the conditionprev_offset + prev_length = next_offset
so in my file the next_offset will be at some random point i will read based on that condition.
please help
below is my code:
fo = open("result.txt") line = fo.readline() while len(line.strip()) != 0 : if "start_indi" in line: line = fo.readline() offset = line.split(':')[0] length = line.split('=')[3] print("["+ offset + ":" + length + "]") line = fo.readline()