Message Boards Message Boards

0
|
5172 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

[?] Change the format of exported float numbers?

Posted 7 years ago

When i export numbers (from a list) to a .txt file that are smaller than $10^{-6}$ (or greater than $10^{6}$), Mathematica uses the Format with an asterisk and circumflex, e. g. exporting 0.000000456 yields 4.56*^-10 in the output file. What I want to have is the "e" format (e. g. 1.46e-7), because I'm reimporting the data to another Notebook and Mathematica gives me an error when I try to plot the data with the other format. I tried using FortranForm[] but the problem is, that the data is in a 2D array, that is Flattened for the export, like in this example:

test = {{1213214.124, 124124121.215, 1252154543.3}, {345, 765, 
    0.000000456}};
Export["data.txt", Flatten[test]];

which gives:

1.213214124*^6
1.24124121215*^8
1.2521545433*^9
345
765
4.56*^-7

what I want is:

1.213214124e6
1.24124121215e8
1.2521545433e9
345
765
4.56e-7

Also it would be important to keep the format of having one number in one line. Your help would be appreciated.

2 Replies

Elias,

Use CSV format and it will work as you request:

Export["data.txt", Flatten[test], "csv"];

or

Export["data.csv", Flatten[test]];

Regards

Neil

POSTED BY: Neil Singer

Thank you very much for the quick answer :-)

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract