Strip lines from files

Caleb a at b.c
Thu Jan 10 15:43:16 CET 2008

Francesco Pietra wrote:
> I am posting again as previous identical message had alleged suspicious header.
> I used successfully script
> f=open("prod1-3_no_wat_pop.pdb", "r")
> for line in f:
> 	line=line.rstrip()
> 	if "WAT" not in line:
> 		print line
> f.close()

log = [[line for line in file(filename,'r') if line.find('WAT')=-1] for 
  filename in filenamelist]
print log

You can populate filenamelist however you like, e.g. with a command-line 
wildcard into sys.argv, or with a os.listdir lookup as in

filenamelist = [filename for filename in os.listdir('.') if 


More information about the Python-list mailing list