[Date Index] [Thread Index] [Author Index]
Re: comma delimited output file -- modify existing code?
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:= stmp = OpenWrite["test.txt"] Out= OutputStream[test.txt, 3] In:= WriteString[stmp, "before, after"] In:= Close[stmp] Out= test.txt In:= !! 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.