Re: comma delimited output file -- modify existing code?
- To: mathgroup at smc.vnet.net
- Subject: [mg31884] Re: [mg31869] comma delimited output file -- modify existing code?
- From: "P.J. Hinton" <paulh at wolfram.com>
- Date: Sun, 9 Dec 2001 06:07:08 -0500 (EST)
- Organization: "Wolfram Research, Inc."
- Sender: owner-wri-mathgroup at wolfram.com
On Sat, 8 Dec 2001, 1.156 wrote: > A year ago or so, some kind soul gave me the very valuable > method of writing a tab delimited array to a text file. Due > to incompetence on my part, I don't have his name. Postings made to this forum are archived and may be searched at this URL: http://library.wolfram.com/mathgroup/ Judging from the arcihves, it looks like the author may have been David Keith. http://library.wolfram.com/mathgroup/archive/1999/Jul/msg00531.html http://library.wolfram.com/mathgroup/archive/1999/Jun/msg00371.html > My data in wList goes nicely into a tab delimited file. > > Now, I'd like to make it a comma delimited file but (again > due to an amazing incompetence) I can't figure out how to > modify it for commas. The "/t" shure looks like the culprit > but when I change it to "/c" I don't get commas but '/c' as > delimiters. So it is the delimiter spec but what is the > comma spec?? Within a Mathematica string, commas do not need escaping. In[1]:= stmp = OpenWrite["test.txt"] Out[1]= OutputStream[test.txt, 3] In[2]:= WriteString[stmp, "before, after"] In[3]:= Close[stmp] Out[3]= test.txt In[4]:= !! test.txt before, after Hence, you should be able to replace "\t" with ",". If you use Mathematica 4.1, the kernel also supports export to CSV format. -- P.J. Hinton User Interface Programmer paulh at wolfram.com Wolfram Research, Inc. Disclaimer: Opinions expressed herein are those of the author alone.