I am trying to read a Fortran double-precision number like 1.2345D+02 into python, but I got the following error:
>>> float('1.2345D+02') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for float(): 1.2345D+02 By following the advice on Python scientific notation using D instead of E, I tried numpy but I also get the same error:
import numpy >>> numpy.float("1.2345D+02") Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for float(): 1.2345D+02 Is there a solution in Python to read those double precision numbers without just changing the 'D' to 'E'?
EDIT: I replaced a bad syntax on the strings. But still I get errors.
fortranformatPython library (on PyPI) can help - I should probably disclose that I'm the author.