MathGroup Archive 2001

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

Search the Archive

comma delimited output file -- modify existing code?

  • To: mathgroup at
  • Subject: [mg31869] comma delimited output file -- modify existing code?
  • From: "1.156" <rob at>
  • Date: Sat, 8 Dec 2001 05:51:46 -0500 (EST)
  • Sender: owner-wri-mathgroup at

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. Anyway,
here is his code that works nicely:

writeArray[filename_, arrayname_] :=
  Module[{makeStringList, outfile}, outfile = OpenWrite[filename];
    makeDepth3[lst_] := Module[{x}, x = lst; While[Depth[x] < 3, x = {x}];
        While[Depth[x] > 3, x = Flatten[x, 1]]; x];
    makeStringList[lst_] :=
            Flatten[Transpose[{Map[ToString, lst],
                  Table["\t", {Length[lst]}]}]], -1], {"\n"}}];
    Scan[WriteString[outfile, Sequence @@ makeStringList[#]] &,
      makeDepth3[arrayname], {1}]; Close[outfile]]

writeArray["filename.txt", wList];

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??

Any help (and/or the ID of the kind soul) would be appreciated.


  • Prev by Date: Re: PowerExpand in mathematica
  • Next by Date: Re: can I add fonts to Mathematica
  • Previous by thread: Re: Solve InterpolatingFunction problem
  • Next by thread: Re: comma delimited output file -- modify existing code?