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

Re: [FWP] joining columns in csv files




Hi all, 
Is my 1st message on this list.
In fact I have copy the Yanick's solution.

On Thu, 16 Nov 2000 yanick1@sympatico.ca wrote:

> On Wed, Nov 15, 2000 at 11:10:33PM -0600, tayers@bridge.com wrote:
> > So far we have the following solutions.
> > 
> > From: fergal daly <fergal@esatclear.ie>
> >   perl -pe'$i=1;s/,/$i++=~m#^4|5|6$#?"":","/ge'     45 chars
> > 
> > Yanick and Larry Rosler had several nice solutions, but they only work
> > for files of 1 line since they don't reset their $i counter. Fixing
> > that glitch gives us
> > 
> > From: yanick1@sympatico.ca
> >   perl -pe'$i=0;s/,/$&if++$i,!grep$i==$_,4,5,6/eg'  48 chars
> >   perl -pe'$i=0;s/,/$&if 4>++$i||$i>6/eg'           39 chars
> >   perl -pe'$i=0;s/,/$&if 1<abs++$i-5/eg'            38 chars
> > 
> > From: "Larry Rosler" <lr@hpl.hp.com>
> >   perl -pe'$i=0;s/,/++$i!~m%^[456]$%&&$&/ge'        42 chars
> >   perl -pe'$i=0;s/,/3<++$i&&$i<7?"":$&/eg'          40 chars
> > 
> > I shortened Yanick's best by one stroke as
> >   perl -pe'$i=0;s/,/1<abs++$i-5&&$&/eg'             37 chars
> 
> 	perl -pe'$i=-5;s/,/1<abs++$i&&$&/eg'              36 chars  :)


	perl -pe'$i=4;s/,/1<abs$i--&&$&/eg'	35 chars 


PM
__

Tomorrow, you can be anywhere.
___


==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe