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

WriteList function?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9320] WriteList function?
  • From: tthomas at ibmoto.com (Tom Thomas)
  • Date: Mon, 27 Oct 1997 02:47:36 -0500
  • Organization: IBM/Motorola Somerset PowerPC Design Center
  • Sender: owner-wri-mathgroup at wolfram.com

Hi, I am a new Mathematica user.  

I have had success reading files of space-separated numbers using
ReadList, but now need to output my results in the same fashion. i.e.
one row of the matrix should appear on one text line, 
     no commas, nor curly braces are desired in the output.

I have searched the manual for a corresponding WriteList function
without success.

Any suggestions?   I may have to resort to awk/sed/perl to  postprocess
the file, but I would've thought Mathematica would've provided the
facilities to write data in a general format.

Thank you kindly,   --tom thomas
-------------------------------------------------------------------
example:
In[1]:= !! /tmp/mymat
1 2 3 
4 5 6
7 8 9

In[1]:= mydata =  ReadList["/tmp/mymat", Number, RecordLists->True]

Out[1]= {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}

In[2]:= stmp = OpenWrite["/tmp/myoutput"]

Out[2]= OutputStream[/tmp/myoutput, 4]

In[3]:= Write[stmp, mydata]


%cat /tmp/myoutput 		
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}

I need to see instead:
1 2 3 
4 5 6
7 8 9


  • Prev by Date: Re: Re: Another Bug in Mathematica 3.0.0 definite integration
  • Next by Date: Re: Fwd: Permutation
  • Previous by thread: Putting Today's Date in Header when Printing?
  • Next by thread: Q: Abs[1+f*I] assuming f>0 and real