[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: VIM command to convert comma delimited text to latex table



On Thu, Feb 21, 2002 at 12:22:51PM +1100, Matthew Dalton wrote:
> Vineet Kumar wrote:
> > 
> > * Abner Gershon (abner_gershon@yahoo.com) [020220 09:01]:
> > > Can someone tell me search and replace commands I can
> > > use to convert comma delimited text in form:
> > > "field 1","field 2","field 3"
> > > to text file to be used in tabular latex file of form:
> > > field 1 & field 2 & field 3
> 
> [cut] 
>  
> > Be careful with the second line if you have quotation marks embedded in
> > your fields, though, even if they're escaped with a backslash or
> > something.
> 
> I would probably get around this by one of two ways. The first (and
> simplest) way it to use 3 commands:
> 
> :%s/","/ \& /g
> :%s/^"//
> :%s/"$//
> 
> ... in other words, change "," to &, then remove the " at the beginning
> of the line and then the one at the end of the line.
> 
> The third way is to do the last 2 commands above in a single search and
> replace instead:
> :%s/^"\(.*\)"$/\1/
> 
> This expression means 'replace all lines starting and ending with a
> quote with the contents of the quotes'.

Umm, what about quoted text containing commas? Like:

"Sound Bite","It was an unfortunate event, but guaranteed to inspire."
 

-- 
Eric G. Miller <egm2@jps.net>



Reply to: