1

I need to write data in scientific notation in a .dat file. For example Export["1.dat", {123.}]. I want to get 1.23e2 in 1.dat. But if I use ScientificForm I can only get ScientificForm[{123.}].

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
XinBae
  • 617
  • 3
  • 9
  • This can help you: https://mathematica.stackexchange.com/a/35375/280 – Alexey Popkov May 16 '18 at 02:00
  • Sorry But i don't think it works.Using his code my export is still 123 not 1.23e2, His method is mainly used to promote speed. – XinBae May 16 '18 at 03:10
  • You can replace FortranForm with ScientificForm or NumberForm (as in the answer by Carl Woll) in that solution in order to get the desired format. – Alexey Popkov May 16 '18 at 04:04

1 Answers1

2

Maybe you can use NumberForm and OutputForm as follows:

Export[
    "tst.dat",
    OutputForm @ NumberForm[
        N @ {Pi, E^3},
        NumberFormat -> (Row[{#1, "e", #3}]&),
        ExponentFunction -> Identity
    ]
];
Import["tst.dat", "String"]

"{3.14159e0, 2.00855e1}"

Carl Woll
  • 130,679
  • 6
  • 243
  • 355
  • Thanks ! it is the format i want.But it caused another problem. How can i remove the{} in "tst.dat"? – XinBae May 16 '18 at 06:34