Search Results

Search found 1 results on 1 pages for 'chromesub'.

Page 1/1 | 1 

  • Python script to remove lines from file containing words in array

    - by chromesub
    I have the following script which identifies lines in a file which I want to remove, based on an array but does not remove them. What should I change? sourcefile = "C:\\Python25\\PC_New.txt" filename2 = "C:\\Python25\\PC_reduced.txt" offending = ["Exception","Integer","RuntimeException"] def fixup( filename ): print "fixup ", filename fin = open( filename ) fout = open( filename2 , "w") for line in fin.readlines(): for item in offending: print "got one",line line = line.replace( item, "MUST DELETE" ) line=line.strip() fout.write(line) fin.close() fout.close() fixup(sourcefile)

    Read the article

1