7
$\begingroup$

Bug introduced in 9.0 and fixed in 9.0.1


I'm trying to load some data into Mathematica from some files generated by fortran. But ReadList seems can't get the number correct.

Here is a simplified version of the problem:

ReadList[StringToStream@" 0.000000000000000000E+00
   0.490953850725349982E-10
   0.135898165173686872E-09
   0.264968686580858939E-09", Number]
(*{0.,4.9095385072534998*10^12709,1.3589816517368687*10^12708,2.6496868658085894*10^12708}*)

In the documentation, it promised that:

ReadList can handle numbers that are given in Fortran-like "E" notation. Thus, for example, ReadList will read 2.5E+5 as 2.5*10^5. Note that ReadList can handle numbers with any number of digits of precision.

Why ReadList can't read this correctly? Is this a bug?

Import can get the numbers correct

Import[Export["/work/mwu3/temp/1234.dat", " 0.000000000000000000E+00
   0.490953850725349982E-10
   0.135898165173686872E-09
   0.264968686580858939E-09"], "List"]
(*{0.,4.9095385072534998*10^-11,1.3589816517368687*10^-10,2.6496868658085894*10^-10}*)

but I have very large data files, Import would take forever. Is there a way to solve it?

Here is my system information:

Mathematica:

9.0 for Linux x86 (64-bit) (November 20, 2012), ReleaseID -> 9.0.0.0

os :

Linux version 2.6.32-358.6.2.el6.x86_64 (mockbuild@x86-022.build.eng.bos.redhat.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC) ) #1 SMP Tue May 14 15:48:21 EDT 2013

$\endgroup$
  • $\begingroup$ It works fine on my system. v9.0.1 Windows 8.1 x64 $\endgroup$ – RunnyKine Oct 15 '13 at 2:38
  • 1
    $\begingroup$ I can confirm that it works properly in v9.0.1 on Windows 8 and gives your results on v9.0.1 on Windows 7. $\endgroup$ – bobthechemist Oct 15 '13 at 2:46
  • $\begingroup$ I'm using Ubuntu Linux 12.04 64 bit and Mathematica 9.0.1 and it works fine here (even on 8.0.4). Can you specify your system in more detail (Linux distribution and version and minor version of Mathematica). Furthermore, I think you should definitely contact Wolfram support. $\endgroup$ – halirutan Oct 15 '13 at 3:27
  • $\begingroup$ It gives the incorrect result in v9.0.0 on Linux 13.04 32 bit. $\endgroup$ – alephalpha Oct 15 '13 at 8:09
  • 1
    $\begingroup$ incorrect with 9.0 -- The issue seems to be with the number of digits, take one digit from the numbers and it works. I think we can fairly call this a bug $\endgroup$ – george2079 Oct 15 '13 at 18:03
3
$\begingroup$

ImportString seems to work:

      First@ImportString[
          " 0.000000000000000000E+00 0.490953850725349982E-10 \
            0.135898165173686872E-09 0.264968686580858939E-09", "Table"]

(* {0., 4.9095385072534998*10^-11, 1.3589816517368687*10^-10, 2.6496868658085894*10^-10} *)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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