Re: writing to a file
- To: mathgroup@smc.vnet.net
- Subject: [mg10259] Re: writing to a file
- From: Allan Hayes <hay@haystack.demon.co.uk>
- Date: Sat, 3 Jan 1998 05:07:14 -0500
- References: <68cssu$a9r@smc.vnet.net>
--------------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>
<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 0.000846 0.000641</TT> <BR><TT>0.02
0.000827 0.000864</TT> <BR><TT>0.03 0.000851
0.000944</TT> <BR><TT>0.04 0.000881 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> "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> </TT><TT></TT>
<P><TT>{0.839164,0.126663,0.71705,0.705989,0.759565,0.676683,0.451329,0.554329,</TT>
<BR><TT> 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> </TT><TT></TT>
<P><TT>0.839164 0.126663 0.71705</TT>
<BR><TT>0.705989 0.759565 0.676683</TT>
<BR><TT>0.451329 0.554329 0.775658</TT>
<BR><TT>0.188611 0.934201 0.401634</TT>
<BR><TT> </TT><TT></TT>
<P><TT>Write["file",</TT>
<BR><TT> OutputForm[TableForm[Partition[data,3],TableSpacing->{0,3}]</TT>
<BR><TT> ]</TT>
<BR><TT>]</TT>
<BR><TT> </TT><TT></TT>
<P><TT>!!file</TT><TT></TT>
<P><TT>0.839164 0.126663 0.71705</TT>
<BR><TT>0.705989 0.759565 0.676683</TT>
<BR><TT>0.451329 0.554329 0.775658</TT>
<BR><TT>0.188611 0.934201 0.401634</TT>
<BR><TT> </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> </TT></HTML>
--------------ECAAD5A932437C06F9B52E3C--