Re: [Tutor] converting string to float

2011-08-10 Thread Steven D'Aprano
Shwinn Ricci wrote: however, I want to convert position to a floating point number, as the actual cell value is in the form of X.XXX (where X = digits). When I try float(position) I get a ValueError saying that the string could not be converted to a float. What am I doing wrong? Inspect the st

Re: [Tutor] converting string to float

2011-08-10 Thread James Reynolds
On Wed, Aug 10, 2011 at 3:16 PM, Shwinn Ricci wrote: > I am reading values from excel using xlrd and using a variable to store > them in (as part of a loop), as such: > > position = sheet.cell(j, i).value > > however, I want to convert position to a floating point number, as the > actual cell va

Re: [Tutor] converting string to float

2011-08-10 Thread Ken
Not sure since a simple float("1.111") worked for me try type() to see what your variable is being returned as. On Wed, Aug 10, 2011 at 3:16 PM, Shwinn Ricci wrote: > I am reading values from excel using xlrd and using a variable to store > them in (as part of a loop), as such: > > position =

[Tutor] converting string to float

2011-08-10 Thread Shwinn Ricci
I am reading values from excel using xlrd and using a variable to store them in (as part of a loop), as such: position = sheet.cell(j, i).value however, I want to convert position to a floating point number, as the actual cell value is in the form of X.XXX (where X = digits). When I try float(po