Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1997
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1997

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

Search the Archive

reply to putting a list to file

  • To: mathgroup at smc.vnet.net
  • Subject: [mg5898] reply to putting a list to file
  • From: lthompso at s.psych.uiuc.edu (Laura Thompson)
  • Date: Sun, 2 Feb 1997 01:33:51 -0500
  • Organization: University of Illinois at Urbana
  • Sender: owner-wri-mathgroup at wolfram.com

Clemens asked me to post this answer:

Hi Laura !
I try to answer your question about putting a list
into a file. So take a list, e.g.

 IN[1]:=l={{1,2},{3,4},{5,6}};

and open a file for writing by assinging a stream to 'str'

 IN[2]:=str=OpenWrite["c:\\testdir\\test.dat"]
 OUT[2]=OutputStream[c:\testdir\test.dat, 17]

(the use of \\ is neccessary under Win311. Perhaps you have
to specify paths in a different way...)
One of the Options of this stream now is

 IN[3]:=Select[Options[str],#[[1]]==FormatType&]
 OUT[3]={FormatType -> InputForm} 

which is not what we actually need, because we want to 
output something. So we have to set this option to

 IN[4]:=SetOptions[str,FormatType->OutputForm];

Now we can write the following 

 IN[5]:=Write[str,TableForm[l]];

After closing the stream

 IN[6]:=Close[str];
 OUT[6]=c:\testdir\test.dat

we can look at the file test.dat :

1   2

3   4

5   6

which is what we desired (hopefully :-))
I hope this helped -
I would appreciate you sending this to the newsgroup
'cause I currently cannot do this ...
Clemens

(-: clemens.frey at uni-bayreuth.de :-)

----------------------------------------------------------------------------

Laura Thompson wrote:
> 
> I would like to put the output of Print[TableForm[mylist]] to a file which
> will _not_ be used by mathematica...
> 
> I have tried Put, >>, opening a stream, Write, and I get either Null, if I
> include the command Print, or the actual list (in list format) if
> I don't include Print.  I would like it in TableForm..in this case one
> column of data.
> 
> Note: it prints fine to the screen.  I have tried to send % to a file (no
> luck) as well as named output...I get Null.
> 
> thanks,
> Laura


  • Prev by Date: Re: Boundary value problems in Mathematica 3.0
  • Next by Date: Help with Convert to InputForm
  • Previous by thread: Re: Re: Boundary value problems in Mathematica 3.0
  • Next by thread: Help with Convert to InputForm