Skip to main content
2 of 11
edited body
Henrik Schumacher
  • 109.5k
  • 7
  • 186
  • 323

After using them for several years, I have to admit that many Export routines in Mathematica are either broken or way to slow (a factor of 10 to 25 when compared to a hand-written "C++" routine, e.g. for such as simple task as exporting an array. Very unfortunate. However, the following can export the data within 2.14 seconds while the OP's version took 15.985 seconds. A hand written C++ routine linked to Mathematica (unfortunately, I cannot export so easily) needs about 0.6 seconds, so in principle, there is still room for improvement.

colsep = " ";
rowsep = "\n";
Export["a.txt",
  Map[
   row \[Function] StringJoin[Riffle[Internal`DoubleToString/@row, colsep], rowsep],
   e
   ]
  ];
Henrik Schumacher
  • 109.5k
  • 7
  • 186
  • 323