|
From: Peter O'R. <pr...@ya...> - 2015-08-08 18:33:50
|
I am reading from a file and convert a columns from a list value to a string.
Then I try and convert from a str to a float, but get this error.
x=float(Amount)
ValueError: invalid literal for __float__:
If I copy the value from the file and assign it to the str variable(Amount), the float function works as expected.
It seems like it might be some type of encoding issue, anyone else have a similar problem? This is the code.
while (lsrc):
valueList = lsrc.split(';')
ltrg = ';'.join(valueList[12:13])
x=ltrg.strip().split('\r\n')
Amount=x[0]
x=float(Amount)
Thanks,
PR |