1
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!)

Jos
  • 31
  • 3
  • 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.

    – Jos May 13 '17 at 08:17
  • Feel free to answer your own question. See also http://reference.wolfram.com/language/tutorial/ExactAndApproximateResults.html – Szabolcs May 13 '17 at 09:16
  • 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. – Jos May 13 '17 at 09:36

1 Answers1

2

Use N[ttt] so it becomes:

ttt=Table[(i+j) 10^(-30), {i, 1}, {j, 2}];
Export["test.dat", N[ttt] , "Table"]
Jos
  • 31
  • 3