Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: formatted table output to ascii file

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97649] Re: formatted table output to ascii file
  • From: dh <dh at metrohm.com>
  • Date: Wed, 18 Mar 2009 04:51:11 -0500 (EST)
  • References: <gpnseu$gqd$1@smc.vnet.net>


Hi,

try e.g. ScvientificForm with Table:

Export["d:/tmp/t.txt",

  ScientificForm[TableForm[d], 4,

   NumberFormat -> (Row[{#1, "e", #3}] &)], "String" ]

hope this helps, Daniel





kuhlen at gmail.com wrote:

> For the life of me I just cannot figure out how to get Mathematica to

> produce nicely formatted (C or Fortran format) output of a 2D table of

> numbers to an ASCII file.

> 

> Let's say I've got this table:

> 

> {{-6., 0.0000243729, 0.0000759669, 0.00187499},

>  {-2., 0.0613641, 0.0827868, 0.0831174},

>  {0.4, 0.317162, 0.307924, 0.33977}}

> 

> I'd like the resulting file to correspond to this C format string

> "%5.2f %10.3e %10.3e %10.3e\n", i.e. to look like this:

> 

> -6.00  2.437e-05  7.597e-05  1.875e-03

> -2.00  6.136e-02  8.279e-02  8.312e-02

>  0.40  3.172e-01  3.079e-01  3.398e-02

> 

> I tried Export["file.dat",table], but got this mess:

> 

> -6.     0.00002437286669095962  0.0000759669270937278

> 0.0018749887943499436

> -1.9999999999999998     0.06136412066687522

> 0.08278680554897219     0.08311737741506361

> 0.40000000000000036     0.31716209930168276

> 0.3079237859649251      0.3397696229714295

> 

> I also tried pre-formatting with something like

> 

> newdata = Map[ToString[PaddedForm[#, {6, 4}]] &, table, {2}];

> 

> but my mathematica-fu isn't good enough to generalize this to the

> desired format.

> 

> Any help would be greatly appreciated!

> 

> mike

> 




  • Prev by Date: Re: Calling functions with huge arguments
  • Next by Date: Re: Calling functions with huge arguments
  • Previous by thread: formatted table output to ascii file
  • Next by thread: Re: formatted table output to ascii file