float does not parse '0.000000E+00'

Darrell Gallion darrell at dorb.com
Sun Jun 4 00:33:36 EDT 2000


Too much work to decode what your doing.
Maybe this will help.

import pprint, string
def parse(lines):
    res=[]
    for l in lines:
        temp = string.split(l)
        resLine=[]
        for n in temp:
            resLine.append(eval(n))

        res.append(resLine)
    return res

pprint.pprint(parse(open("lcase.001").readlines()))

############ Output
[[1],
 [4, 3],
 [1, 0.0, 0.0],
 [2, 0.0, 300.0],
 [3, 500.0, 300.0],
 [4, 500.0, 0.0],
 [1, 1, 2],
 [2, 2, 3],
 [3, 3, 4],
 [1, 300.0, 0.0, 1.0],
 [0.0, 0.0, 0.0, 2500.0, -146.922, 6526.54],
.....

--Darrell Gallion




Paolo Redaelli wrote:
> 
> but if I run a program that does x=float(x) where x = "0.000000E+00 "
> (being a string) here's the output. 
> 
> ===========================
> [paolo at aldebaran Telaio]$ ./pyplot.py
> x(<type 'string'>)='0.000000E+00' y(<type 'string'>)='0.000000E+00'
> Traceback (innermost last):
>   File "./pyplot.py", line 198, in ?
>     t = Telaio()
>   File "./pyplot.py", line 172, in __init__
>     x = float(x)
> ===========================






More information about the Python-list mailing list