MathGroup Archive 2006

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

Search the Archive

Re: Add Quotation Marks to Data in a file

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69768] Re: [mg69726] Add Quotation Marks to Data in a file
  • From: János <janos.lobb at yale.edu>
  • Date: Fri, 22 Sep 2006 01:04:51 -0400 (EDT)
  • References: <200609211131.HAA07846@smc.vnet.net>

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

Here is a very newbie approach:

When yo write them out first convert the 6 x 6 to string with  
something like ToString[Unevaluated[6 x 6]] and write it out as a  
Word type.

János
P.S.  Now if
In[25]:=
StringJoin[\",ToString[Unevaluated[6x6]],\"]

would give back a visible "6 x 6" then life would be much easier.  \"  
should represent the literal " according to A.2.3, but I am getting

In[25]:=
StringJoin[\",ToString[Unevaluated[6x6]],\"]
 From In[25]:=
\!\(\*
   RowBox[{\(Syntax::"tsntxi"\),
     ":", "\<\"\\\"\\!\\(StringJoin[\\(\\(\\*\\\"\\\\\\\\\\\\\\\"\\\"\ 
\)\\), \
\\(\\(ToString[\\(\\(Unevaluated[\\(\\(6x6\\)\\)]\\)\\)]\\)\\), \\(\\ 
(\\*\\\"\
\\\\\\\\\\\\\\\"\\\"\\)\\)]\\)\\\" is incomplete; more input is  
needed.\\!\\(\
\\\"\\\"\\) \\!\\(\\*ButtonBox[\\\"More\[Ellipsis]\\\", \
ButtonStyle->\\\"RefGuideLinkText\\\", ButtonFrame->None, \
ButtonData:>\\\"General::tsntxi\\\"]\\)\"\>"}]\)
 From In[25]:=
StringJoin[\",ToString[Unevaluated[6x6]],\"]
 From In[29]:=
StringJoin[\",ToString[Unevaluated[6x6]],\"]
 From In[29]:=
Syntax::"tsntxi":"\"\!\(StringJoin[\(\(\*\"\\\\\\\"\"\)\), \
\(\(ToString[\(\(Unevaluated[\(\(6x6\)\)]\)\)]\)\), \(\(\*\"\\\\\\ 
\"\"\)\)]\
\)\" is incomplete; more input is needed.\!\(\"\"\) \!\(\*ButtonBox 
[\"More\
\[Ellipsis]\", ButtonStyle->\"RefGuideLinkText\", ButtonFrame->None, \
ButtonData:>\"General::tsntxi\"]\)"
 From In[29]:=
StringJoin[\",ToString[Unevaluated[6x6]],\"]


  • Prev by Date: Re: Warning Message wrt NMinimize function
  • Next by Date: animation
  • Previous by thread: Re: Add Quotation Marks to Data in a file
  • Next by thread: Re: Re: Add Quotation Marks to Data in a file