[Tutor] converting string to float

Shwinn Ricci armvrt at gmail.com
Wed Aug 10 21:16:27 CEST 2011


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(position) I get a ValueError saying that the string could not be
converted to a float. What am I doing wrong?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110810/34f96513/attachment.html>


More information about the Tutor mailing list