I have a program that saves a .txt log with multiple values and text. Those are time values can differ each time the program is ran, but their place in this .txt file is always the same. I need to grab those values and check if they are smaller than 6 seconds. I was trying to convert my .txt file to string, and then use:
x = string(filename[50:55])
float(x)
But it doesn't seem to work. How can I extract values form fixed place in .txt file and then convert them to float number?
//EDIT:
Photo of my log below, I want to check those values marked with blue line:
//EDIT2:
Photo of another log, how would I extract those percentages, those must be below 70 to pass.
//EDIT3:Photo of the error I got and fragment of the code:
with open(r'C:\Users\Time_Log.txt') as f:
print(f)
lines = f.readlines()
print(r'Lines: ')
print(lines)
print(r'Type of lines:', type(lines))
# start at 1 to avoid the header
for line in range(1, len(lines)):
print(r'Type of line:', type(line))
splits = line.split("|")
print(r'Type of splits:', type(splits))
t = splits[3].split(".")
if t[0] < 6:
print(r'Test completed. Startup time is shorter than 6 seconds')