I'm trying to extract a float from a line in a text file, but i can't for the life of me understand how to convert the number in the line (str) into a float
for line in fh:
if not line.startswith("A specific string") : continue
count = count + 1
#linevalue gets the numbers in the line that i'm interested in, so in order
#to have only the numeric value i tried getting rid of the other text in the line by only
# selecting that range (20:26
linevalue = line[20:26]
float(linevalue)
print type(linevalue)
print linevalue
the attempted conversion with float(linevalue) is not going through, the output of the program remains e.g:
<type 'str'> 0.4323
Can anyone help me understand what am I missing ?
Thank you very much for your time.