Re: Add Quotation Marks to Data in a file
- To: mathgroup at smc.vnet.net
- Subject: [mg69810] Re: [mg69726] Add Quotation Marks to Data in a file
- From: Dean Williams <deanwilliams at mac.com>
- Date: Sat, 23 Sep 2006 23:44:59 -0400 (EDT)
John,
Try
oldFile=Import["test.csv","CSV"]
newFile=Map[ReplacePart[#,StringJoin[FromCharacterCode[34],Part[#,2],
FromCharacterCode[34]],2]&,oldFile]
Out[750]=
{{Circle,6 x 6,5,0.23},{Circle,7 x 7,5,0.29}}
Out[751]=
{{Circle,"6 x 6",5,0.23},{Circle,"7 x 7",5,0.29}}
Dean
On Sep 21, 2006, at 7:31 AM, JOHN ERB 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
>
>