MathGroup Archive 1999

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

Search the Archive

Re: Convert 2D list to delimited text?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg16686] Re: Convert 2D list to delimited text?
  • From: adam.smith at hillsdale.edu
  • Date: Sat, 20 Mar 1999 02:08:59 -0500
  • Organization: Deja News - The Leader in Internet Discussion
  • References: <7ct6pm$8a0@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <7ct6pm$8a0 at smc.vnet.net>,
  "David P. Johnson" <johnson at ae.msstate.edu> wrote:
> I'm trying to convert a 2D list of lists to delimited text. For example:
>
>   {{x1,y1},{x2,y2},...,{xn,yn}}
>
> to
>
>   x1,y1
>   x2,y2
>    ...
>   xn,yn
>
> Is there any easy way to do this? Thanks.
>
> --
> David
> ->(Signature continues here)
>
>
David,

If you want to just have a "nice" display in Mathematica try the following:
In[1]:=  mylist = {{x1,y1},{x2,y2},{x3,y3}}
In[2]:=  MatrixForm[mylist]

If you want to put it on the screen with commas use:
In[3]:=   For[nmax=Length[mylist];i=1,i<= nmax,
              Print[ mylist[[i,1]],",",  mylist[[i,2]]];i++]

And lastly, if you want to output it to a text file (for reading from another
program, for example"
In[4]:=  strm=OpenWrite["temp2.txt",FormatType->OutputForm]

          For[nmax=Length[mylist];i=1,i<= nmax,
           Write[strm, mylist[[i,1]],",",mylist[[i,2]]];i++,
           FormatType->OutputForm]

         Close[strm]
Hope that helps

Adam Smith

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


  • Prev by Date: Re: 2D list of lists to delimited text?
  • Next by Date: Re: Help me! - SphericalPlot
  • Previous by thread: Convert 2D list to delimited text?
  • Next by thread: Re: Convert 2D list to delimited text?