728x90 AdSpace

Latest News
Monday, April 8, 2013

Python Script for Multiple Delete in Multiple files


 To delete/replace few words from few text files.

 Find and Replace feature will not be that much effective and cannot be used, if there are too many files to edit.
The following python script will help in such situation to replace specific words from the files
 
#filename =filename

infile = “input.txt”
outfile= "newfile.txt"

delete_list = [“word 1”,”word 2”…..etc ]

fin = open(infile)
fout = open(outfile, “w+”)
for line in fin:
line = line.replace(word, “”)
fout.write(line)
fin.close() 


Jeyanthan Inbasekaran
 CollabNet Software Private Limited, Chennai
  • Blogger Comments
  • Facebook Comments

0 comments:

Post a Comment

Item Reviewed: Python Script for Multiple Delete in Multiple files Rating: 5 Reviewed By: Praveen Kumar Rajendran