I'm trying to read the output file of a simulation and grap some data (elapsed CPU time). I've tried multiple ways of doing this. But I can't get past one row in the file, that seems to work like an escape character.
This is the last row (row 92 of 3846) Python detects in the file:
expanding memory to 6775753 d 3496497
After this the function stops reading the file.
It's not a big file (189KB).
Is there any way of skipping this row? A solution that starts reading the file from the back would be sufficient as well, since the data I'm trying to access is towards the end of the file.
This is the code I'm trying to use. I tried to read the file in binary, but it didn't solve my problem.
txt_file = os.path.join(dir_register, 'messag')
with open(txt_file, 'r+b') as txt:
for line in txt.readlines():
if 'Total CPU time'.encode() in line:
cpu_time = float(line.split()[4])