MathGroup Archive 1998

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

Search the Archive

Re: writing to a file



--------------ECAAD5A932437C06F9B52E3C


lichtner@swri.edu wrote:

> I am using Mathematica 3.0.0 running under NeXTSTEP 3.3. I would like to
> be able to write a sequence of numbers to a file formatted so that the
> numbers are separated by e.g. spaces. For example:
>
> 0.01  0.000846  0.000641
> 0.02  0.000827  0.000864
> 0.03  0.000851  0.000944
> 0.04  0.000881  0.000974
> etc.
>
> ___________________________________

Following a recent posting of David Withoff

 "If you can get what you want on the computer screen[in OutputForm],
then you can write
it to a file"

data=Table[Random[], {12}]


{0.839164,0.126663,0.71705,0.705989,0.759565,0.676683,0.451329,0.554329,
  0.775658,0.188611,0.934201,0.401634}

result=OutputForm[TableForm[Partition[data,3],TableSpacing->{0,3}]]


0.839164   0.126663   0.71705
0.705989   0.759565   0.676683
0.451329   0.554329   0.775658
0.188611   0.934201   0.401634


Write["file",
 OutputForm[TableForm[Partition[data,3],TableSpacing->{0,3}]
 ]
]


!!file

0.839164   0.126663   0.71705
0.705989   0.759565   0.676683
0.451329   0.554329   0.775658
0.188611   0.934201   0.401634

--
Allan Hayes
Training and Consulting
Leicester, UK
hay@haystack.demon.co.uk
http://www.haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44 (0)116 271 8642


--------------ECAAD5A932437C06F9B52E3C

<HTML>
&nbsp;

<P><TT>lichtner@swri.edu wrote:</TT> <BLOCKQUOTE TYPE=CITE><TT>I am
using Mathematica 3.0.0 running under NeXTSTEP 3.3. I would like
to</TT>
<BR><TT>be able to write a sequence of numbers to a file formatted so
that the</TT>
<BR><TT>numbers are separated by e.g. spaces. For example:</TT><TT></TT>

<P><TT>0.01&nbsp; 0.000846&nbsp; 0.000641</TT> <BR><TT>0.02&nbsp;
0.000827&nbsp; 0.000864</TT> <BR><TT>0.03&nbsp; 0.000851&nbsp;
0.000944</TT> <BR><TT>0.04&nbsp; 0.000881&nbsp; 0.000974</TT>
<BR><TT>etc.</TT><TT></TT>

<P><TT>___________________________________</TT></BLOCKQUOTE>
<TT>Following a recent posting of David Withoff</TT><TT></TT>

<P><TT>&nbsp;"If you can get what you want on the computer screen[in
OutputForm], then you can write</TT>
<BR><TT>it to a file"</TT><TT></TT>

<P><TT>data=Table[Random[], {12}]</TT> <BR><TT>&nbsp;</TT><TT></TT>

<P><TT>{0.839164,0.126663,0.71705,0.705989,0.759565,0.676683,0.451329,0.554329,</TT>
<BR><TT>&nbsp; 0.775658,0.188611,0.934201,0.401634}</TT><TT></TT>

<P><TT>result=OutputForm[TableForm[Partition[data,3],TableSpacing->{0,3}]]</TT>
<BR><TT>&nbsp;</TT><TT></TT>

<P><TT>0.839164&nbsp;&nbsp; 0.126663&nbsp;&nbsp; 0.71705</TT>
<BR><TT>0.705989&nbsp;&nbsp; 0.759565&nbsp;&nbsp; 0.676683</TT>
<BR><TT>0.451329&nbsp;&nbsp; 0.554329&nbsp;&nbsp; 0.775658</TT>
<BR><TT>0.188611&nbsp;&nbsp; 0.934201&nbsp;&nbsp; 0.401634</TT>
<BR><TT>&nbsp;</TT><TT></TT>

<P><TT>Write["file",</TT>
<BR><TT>&nbsp;OutputForm[TableForm[Partition[data,3],TableSpacing->{0,3}]</TT>
<BR><TT>&nbsp;]</TT>
<BR><TT>]</TT>
<BR><TT>&nbsp;</TT><TT></TT>

<P><TT>!!file</TT><TT></TT>

<P><TT>0.839164&nbsp;&nbsp; 0.126663&nbsp;&nbsp; 0.71705</TT>
<BR><TT>0.705989&nbsp;&nbsp; 0.759565&nbsp;&nbsp; 0.676683</TT>
<BR><TT>0.451329&nbsp;&nbsp; 0.554329&nbsp;&nbsp; 0.775658</TT>
<BR><TT>0.188611&nbsp;&nbsp; 0.934201&nbsp;&nbsp; 0.401634</TT>
<BR><TT>&nbsp;</TT>
<BR><TT>--</TT>
<BR><TT>Allan Hayes</TT>
<BR><TT>Training and Consulting</TT> <BR><TT>Leicester, UK</TT>
<BR><TT>hay@haystack.demon.co.uk</TT> <BR><TT><A
HREF="http://www.haystack.demon.co.uk">http://www.haystack.demon.co.uk</A></TT>
<BR><TT>voice: +44 (0)116 271 4198</TT> <BR><TT>fax: +44 (0)116 271
8642</TT> <BR><TT>&nbsp;</TT></HTML>

--------------ECAAD5A932437C06F9B52E3C--



  • Prev by Date: RE: Complex Function
  • Next by Date: Together and Simplify
  • Prev by thread: RE: Complex Function
  • Next by thread: Re: writing to a file