I have a file that has 'word'\t'num'\n
as a string. I would like to convert it to a dictionary which I have done except how to a convert the value 'num' to a floating point number, so that the dict is of this format `{word : num} and the num is not a string but a floating point number.
Here is my script so far:
file_stream = open(infile)
file_list = file_stream.readlines()
dict_output = {}
for line in file_list:
tmp = line.split()
dict_output[tmp[0]] = float(tmp[1])
If I remove the float()
the script runs fine and it creates a dictionary with the values as strings. When I try to cast the string as an int I get the error message:
"ValueError: could not convert string to float: stand"