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


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 ?

  • $\begingroup$ Read as text, then use something like ToExpression[StringReplace[nums, "E" -> "*10^"]] on that list. However, ReadList[...,Number] should handle the Fortran style. $\endgroup$ – ciao Apr 5 '14 at 6:27
  • $\begingroup$ Related mathematica.stackexchange.com/questions/33498/… $\endgroup$ – ciao Apr 5 '14 at 6:51
  • $\begingroup$ 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? $\endgroup$ – Mr.Wizard Apr 5 '14 at 6:53
  • $\begingroup$ Also related: How to convert a string of number into real numbers without precision loss $\endgroup$ – Mr.Wizard Apr 5 '14 at 6:54
  • $\begingroup$ @Mr.Wizard: Looks like a possible bug in V9... $\endgroup$ – ciao Apr 5 '14 at 7:13

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

  • $\begingroup$ Incidentally in version 7 Import does not work fully here: data is imported as machine reals, losing input precision. $\endgroup$ – Mr.Wizard Apr 5 '14 at 6:59

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