1
$\begingroup$
ttt=Table[(i + j) 10^(-30), {i, 1}, {j, 2}];
Export["test.dat", ttt, "Table"]

This gives notation1/500000000000000000000000000000, but I need 2.0000e-30 or similar in the file (i.e, Fortran-readable).

Somewhere I probably need to use FortranForm, NumberFormat, ExponentFunction, or some other coercion, but I cannot find it in any of the existing discussions on the web (I do see answers but none of them actually works!)

$\endgroup$
4
  • $\begingroup$ After some trying, it seems that the actual (short) answer is to use N[ttt] : ttt=Table[(i+j) 10^(-30), {i, 1}, {j, 2}]; Export["test.dat", N[ttt] , "Table"] So unless I overlooked something, this seems to be the most basic way of writing a Fortran-readable table. $\endgroup$
    – Jos
    May 13 '17 at 8:17
  • $\begingroup$ Take a look a some of the answers to How to export data files using specific format $\endgroup$
    – LouisB
    May 13 '17 at 8:49
  • $\begingroup$ Feel free to answer your own question. See also reference.wolfram.com/language/tutorial/… $\endgroup$
    – Szabolcs
    May 13 '17 at 9:16
  • $\begingroup$ No it is not a duplicate of the discussion "How to export data files using specific format" because there, the solution using N[ ] is not even mentioned! That was exactly my problem: all earlier discussions seemed to veer off into obfuscated work-arounds. But the solution now that I found it, is much simpler. $\endgroup$
    – Jos
    May 13 '17 at 9:36
2
$\begingroup$

Use N[ttt] so it becomes:

ttt=Table[(i+j) 10^(-30), {i, 1}, {j, 2}];
Export["test.dat", N[ttt] , "Table"]
$\endgroup$

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