[Numpy-discussion] Re ading scientific notation using D instead of E
Dag Sverre Seljebotn
dagss@student.matnat.uio...
Fri Feb 12 10:08:28 CST 2010
josef.pktd@gmail.com wrote:
> On Fri, Feb 12, 2010 at 11:03 AM, <josef.pktd@gmail.com> wrote:
>
>> On Fri, Feb 12, 2010 at 10:46 AM, Robert C. <ricitron@mac.com> wrote:
>>
>>> I am trying to read a large amount of data that is output in scientific
>>> notation using D instead of E. After searching around I found a thread that
>>> implied numpy already has the capability to do this:
>>> http://stackoverflow.com/questions/1959210/python-scientific-notation-using-d-instead-of-e
>>> http://stackoverflow.com/questions/1959210/python-scientific-notation-using-d-instead-of-e
>>>
>>> However, this does not work for me. I get:
>>>
>>>
>>>>>> numpy.float('1.23D+04')
>>>>>>
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in <module>
>>> ValueError: invalid literal for float(): 1.23D+04
>>>
>>> Was this capability lost in more recent versions of numpy?
>>>
>>> I would rather not have to do a search and replace every time I read in
>>> data.
>>>
>>>>> np.float('1.5698D+03')
>>>>>
>> 1569.8
>>
>>>>> np.float('1.23D+04')
>>>>>
>> 12300.0
>>
>> it's still working with numpy 1.4.0
>>
>
> maybe this is a python feature with python builtin float:
>
>
>>>> float('1.5698D+03')
>>>>
> 1569.8
>
>>>> float('123D+04')
>>>>
> 1230000.0
>
> with python 2.5
>
With Python 2.6, I get "Invalid literal for float".
Dag Sverre
More information about the NumPy-Discussion
mailing list