LOADING DATA INTO ARRAYS

Skip Montanaro skip at pobox.com
Wed Jul 9 14:43:08 EDT 2003


Don't forget to cc the list.  You get more people looking at your problem

    satish> The data of "fluidcylinder" is as folllows:

    satish> 1.00000000000000        0.00000000000000D+000   0.00000000000000D+000
    satish> 0.932113519778473       0.362166241174114        0.00000000000000D+000

    satish> I am getting the following error:

    satish>  xval,yval,zval=map(float,line.split())
    satish> ValueError: invalid literal for float(): 0.00000000000000D+000

It's been many years since I programmed any Fortran, so I'm no longer sure
what the 'D' notation stands for (double-precision?).  As a first guess, I'd
suggest you change the 'D's to 'E's:

    >>> line.replace('D', 'E').split()
    ['1.00000000000000', '0.00000000000000E+000', '0.00000000000000E+000']
    >>> map(float, line.replace('D', 'E').split())
    [1.0, 0.0, 0.0]

Skip






More information about the Python-list mailing list