Re: Add Quotation Marks to Data in a file

*To*: mathgroup at smc.vnet.net*Subject*: [mg69744] Re: [mg69726] Add Quotation Marks to Data in a file*From*: "Chris Chiasson" <chris at chiasson.name>*Date*: Fri, 22 Sep 2006 01:04:12 -0400 (EDT)*References*: <200609211131.HAA07846@smc.vnet.net>

Assuming those entries 6 x 6 are strings inside Mathematica, you could just replace them using string expressions. In[1]:= xpr[1]={{a,b,"6 x 6"},{c,"5 x 4",z}}; ExportString[xpr[1],"CSV"] Out[2]= a,b,6 x 6 c,5 x 4,z In[3]:= xpr[2]=xpr[1]/.blah_String:> StringReplace[blah,(a__~~"x"~~b__):>"\""~~a~~"x"~~b~~"\""]; ExportString[xpr[2],"CSV"] Out[4]= a,b,"6 x 6" c,"5 x 4",z On 9/21/06, JOHN ERB <john_c_erb at prodigy.net> wrote: > I have a comma-separated file (CSV) that looks like > > Circle, 6 x 6, 5, 0.23 > Circle, 7 x 7, 5, 0.29 > ... > > How do I add quotation marks around the second element > so that when I export the data to an CSV file, I get > > Circle, "6 x 6", 5, 0.23 > Circle, "7 x 7", 5, 0.29 > ... > > Thank you > John C. Erb > > -- http://chris.chiasson.name/

**References**:**Add Quotation Marks to Data in a file***From:*JOHN ERB <john_c_erb@prodigy.net>