Re: Print numbers to ASCII file with precise column widths
- To: mathgroup at smc.vnet.net
- Subject: [mg100466] Re: Print numbers to ASCII file with precise column widths
- From: JAC <jconant at aerodyne.com>
- Date: Fri, 5 Jun 2009 03:00:14 -0400 (EDT)
- References: <gvq0c8$muk$1@smc.vnet.net> <h050jh$aa2$1@smc.vnet.net>
Dan's solution works excellently (thanks so much!). I have made it a
function ("eFormatPrint"), and I combined it with an "f-format"
function (using PaddedForm) to give me a "gFormat" function with
string output like [you need to view in a non-proportional font]:
For[i = 1, i <= Length[data], i++,
Print[ gFormatPrint[ data[[i]], 10, 3] ]
]
1.235
1.235e7
1.235e-12
-1.235e-12
2.000
11.000
[With a fixed font, each value lines up right-justified in column 10}.
I've put these into a package "NumericalFileIO", useful for formatted
ASCII read and writes.