Re: Convert 2D list to delimited text?
- To: mathgroup at smc.vnet.net
- Subject: [mg16728] Re: [mg16669] Convert 2D list to delimited text?
- From: "Tomas Garza" <tgarza at mail.internet.com.mx>
- Date: Wed, 24 Mar 1999 02:23:46 -0500
- Sender: owner-wri-mathgroup at wolfram.com
David P. Johnson 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,
Say
In[1]:=
lista1=Table[{Random[Integer,{1,10}],Random[Integer,{1,10}]},{10}]
Out[1]=
{{5,9},{4,6},{4,10},{7,4},{3,1},{1,9},{9,4},{9,10},{3,1},{1,6}}
Then
In[2]:=
b={ToString[#[[1]]]<>","<>ToString[#[[2]]]}&/@lista1
Out[2]=
{{"5,9"},{"4,6"},{"4,10"},{"7,4"},{"3,1"},{"1,9"},{"9,4"},{"9,10"},{"3,1"},{
"1,6"}}
does what you want. If you want to display the result as a column use
TableForm[b]
Tomas Garza
Mexico City