MathGroup Archive 1998

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

Search the Archive

Re: Output to a file

  • To: mathgroup at smc.vnet.net
  • Subject: [mg13250] Re: [mg13215] Output to a file
  • From: David Withoff <withoff>
  • Date: Fri, 17 Jul 1998 03:17:45 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

> Hi,
>
> I'm trying to output values to a file. The result should look like this
>
>
>   -24.0000  -20.0000  2.5432  1.3894  2.3965  2.3490
>
> I already came across 'PaddedForm' - but
>
>   Write[fileNr,PaddedForm[{x,y,fp1[xx,yy]},{7,4}]
>
> gives
>
>   {-24.0000,  -20.0000,  2.5432,  1.3894,  2.3965,  2.3490}
>
> How do I get rid of '{' and ','  ????
>
> Michaela

The best way to do this will depend on the details of what you want to
do.  Here are four possibilities:

In[1]:= data = {-24.0000,  -20.0000,  2.5432,  1.3894,  2.3965,  2.3490}
;

In[2]:= PaddedForm[TableForm[data,TableDirections->Row],{7,4}]

Out[2]//PaddedForm=

>    -24.0000  -20.0000    2.5432    1.3894    2.3965    2.3490

In[3]:=  PaddedForm[TableForm[{data}],{7,4}]

Out[3]//PaddedForm=

>    -24.0000    -20.0000      2.5432      1.3894      2.3965      2.3490

In[4]:= PaddedForm[SequenceForm  @@ data,{7,4}]

Out[4]//PaddedForm=  -24.0000 -20.0000   2.5432   1.3894   2.3965  
2.3490

In[5]:= Infix[PaddedForm[#,{7,4}]& /@ data, " ", 100]

Out[5]=  -24.0000  -20.0000    2.5432    1.3894    2.3965    2.3490

Writing these things to a file is similar to displaying them (in
OutputForm) on the computer screen.  For example,

In[6]:= Write["file", OutputForm[PaddedForm[TableForm[{data}],{7,4}]]]

In[7]:= !!file
 -24.0000    -20.0000      2.5432      1.3894      2.3965      2.3490

will put this output in a file.

Dave Withoff
Wolfram Research


  • Prev by Date: CPU times
  • Next by Date: Re: Re: Integrate Bug?
  • Previous by thread: Output to a file
  • Next by thread: Re: Output to a file