views:

81

answers:

2

I get output files from very old Fortran programs, which look like:

 0.81667E+00  -0.12650E+01  -0.69389E-03
 0.94381E+00  -0.11985E+01  -0.11502E+00
 0.96064E+00  -0.11333E+01  -0.17616E+00
 0.10202E+01  -0.12435E+01  -0.93917E-01
 0.10026E+01  -0.10904E+01  -0.15108E+00
 0.90516E+00  -0.11030E+01  -0.19139E+00
 0.98624E+00  -0.11598E+01  -0.22970E+00

Is it possible to read this in Python and convert the numbers to "normal" floats?

+3  A: 
Python 2.6.1 (r261:67515, Jul  7 2009, 23:51:51) 
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> float('-0.69389E-03')
-0.00069388999999999996
fuzzy lollipop
sorry. thanks a lot
Werner
+1  A: 
>>> line="0.81667E+00  -0.12650E+01  -0.69389E-03"
>>> map(float,line.split())
[0.81667000000000001, -1.2649999999999999, -0.00069388999999999996]
gnibbler