Need help with a program

Johann Spies jspies at sun.ac.za
Fri Jan 29 14:21:40 CET 2010


On Fri, Jan 29, 2010 at 10:04:33AM +0000, Steven D'Aprano wrote:
> > I know this is a python list but if you really want to get the job done
> > quickly this is one method without writing python code:
> > 
> > $ cat /tmp/y
> > AAAAAGACTCGAGTGCGCGGA   0
> > AAAAAGATAAGCTAATTAAGCTACTGG     0
> > AAAAAGATAAGCTAATTAAGCTACTGGGTT   1
> > AAAAAGGGGGCTCACAGGGGAGGGGTAT     1
> > AAAAAGGTCGCCTGACGGCTGC  0
> > $ grep -v 0 /tmp/y > tmp/z
> > $ cat /tmp/z
> > AAAAAGATAAGCTAATTAAGCTACTGGGTT   1
> > AAAAAGGGGGCTCACAGGGGAGGGGTAT     1
> 
> That will do the wrong thing for lines like:
> 
> AAAAAGATAAGCTAATTAAGCTACTGGGTT   10

In that case change the grep to ' 0$'  then only the lines with a
singel digit '0' at the end of the line will be excluded.

One can do the same using regulare expressions in Python and it will
probably a lot slower on large files.

Regards
Johann
-- 
Johann Spies          Telefoon: 021-808 4599
Informasietegnologie, Universiteit van Stellenbosch

     "My son, if sinners entice thee, consent thou not."    
                            Proverbs 1:10 



More information about the Python-list mailing list