Re: Re: writing mathematica data to a tab delimited file??
- To: mathgroup at smc.vnet.net
- Subject: [mg18425] Re: [mg18355] Re: [mg18337] writing mathematica data to a tab delimited file??
- From: "Tomas Garza" <tgarza at mail.internet.com.mx>
- Date: Wed, 7 Jul 1999 00:11:17 -0400
- Sender: owner-wri-mathgroup at wolfram.com
> Try this:
>
> In[1]:=mylist=Table[{1, x}, {x, 1, 10, 1}]
>
> In[3]:=temporal=OpenWrite["mylist.txt"];
> Do[WriteString[tmp,
> StringTake[
> StringReplace[ToString[Part[mylist,i]],","->"\t"]
> ,{2,StringLength[ToString[Part[mylist,i]]]-1}],"\n"]
> ,{i,1, Length[mylist]}];
> Close[temporal]
This has been a usual problem for novice Mathematica users. Mathematica 4
has, at last, given us a built-in solution. Cf. the function Export:
Export["file.ext", expr] exports data to a file, converting it to a format
corresponding to the file extension ext.
Export["file", expr, "format"] exports data to a file, converting it to the
specified format.
Tomas Garza
Mexico City
>
> At 3:11 PM -0400 99.6.27, Mike wrote:
> > I frequently read data into mathematica that has been given to me as a
> > two column tab delimited text file. Is their some way of saving a
> > mathematica list eg.
> >
> > mylist=Table[{1, x}, {x, 1, 10, 1}]
> >
> >
> > as a file in a tab delimited two column format
> >
> > 1 1
> > 1 2
> > 1 3
> > 1 4
> >
> > etc.
> >
> >
> >
> > to be read by other people in eg. excel or sigma plot?
> >
> > thanks
> >
> > Mike