Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

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: [mg69764] Re: Add Quotation Marks to Data in a file
  • From: dh <dh at metrohm.ch>
  • Date: Fri, 22 Sep 2006 01:04:45 -0400 (EDT)
  • References: <eetvns$at8$1@smc.vnet.net>

Hi John,
read the files as text. Add quotes and write the new file:
t=Import["d:/tmp/t.txt","Lines"];
t=StringInsert[#,"\"",{9,14}]& /@ t;
Export["d:/tmp/t1.txt",t,"Lines"];
For more complicated cases, you may use StringReplace instead of 
StringInsert.

Daniel
OHN 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
> 


  • Prev by Date: Re: Programming in Mathematica
  • Next by Date: Re: Re: Why is the negative root?
  • Previous by thread: Re: Re: Add Quotation Marks to Data in a file
  • Next by thread: Re: Add Quotation Marks to Data in a file