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.
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()
CollabNet Software Private Limited, Chennai
0 comments:
Post a Comment