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.}].
Asked
Active
Viewed 187 times
1
1 Answers
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
FortranFormwithScientificFormorNumberForm(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