Delete lines which contain string in a file

Steve Holden steve at holdenweb.com
Wed Feb 18 17:24:20 EST 2009


Rudi Goldman wrote:
> Hi,
> Go easy on me as I am a new to Python and am trying to solve a practical
> problem that is driving me bananas.
> Basically I have 2 text files, a source and a target. I want to be able
> to delete all of the lines in the target file which contain text from
> any line in the source file.
> i.e.
> Source:                                     Target:
> 111                                           xxx 111 yyy   
> 222                                           xxx  333 sss 
> 333                                           jjj   444 sss
> 
> After executing this code the target file should only consist of the
> line:     jjj   444 sss
> Any help on this one would be greatly appreciated.
> 
Is this homework?

How far have you got with your design?

regards
 Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC              http://www.holdenweb.com/




More information about the Python-list mailing list