Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

Now, I have a data file (abc.dat) and it includes many long-Fortran-like numerical numbers as follows,

 6.329743394299864138426200801048403E-0008
-2.549598515596261539775494416553164E-0005
-4.070996338361811028817170114484442E-0005

How to read these data in Mathematica? If we use ReadList["abc.dat",Real] and it is not available for these long numbers. If we use ReadList["abc.dat", Record], then we need to find a way to change the string to numbers. Is there some better way for dealing with this problem ?

share|improve this question

marked as duplicate by m_goldberg, bobthechemist, rasher, Sjoerd C. de Vries, Michael E2 Apr 6 at 17:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Read as text, then use something like ToExpression[StringReplace[nums, "E" -> "*10^"]] on that list. However, ReadList[...,Number] should handle the Fortran style. –  rasher Apr 5 at 6:27
    
    
In version 7 ReadList["abc.dat", Real] appears to work correctly, yielding: {6.32974339429986413842620080104840*10^-8, -0.0000254959851559626153977549441655316, -0.0000407099633836181102881717011448444}. What output do you get? –  Mr.Wizard Apr 5 at 6:53
    
    
@Mr.Wizard: Looks like a possible bug in V9... –  rasher Apr 5 at 7:13

1 Answer 1

I opened HxD and pasted your numbers and saved as abc.dat. Then this worked for (8.0.4.0):

Import["C:\\f1\\f2\\Desktop\\abc.dat"]
(*{{6.32974339429986413842620080104840\[CenterDot]10^-8},{-0.0000254959851559626153977549441655316},{-0.0000407099633836181102881717011448444}}*)
share|improve this answer
    
Incidentally in version 7 Import does not work fully here: data is imported as machine reals, losing input precision. –  Mr.Wizard Apr 5 at 6:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.