I have a bunch of HTML files in HTML folder. Those HTML files have unicode characters which I solved by using filter(lambda x: x in string.printable, line)
. Now how do I write the changes back to the original file? What is the best way of doing it? Each HTML file is of 30 kb in size.
1 import os, string
2
3 for file in os.listdir("HTML/"):
4 print file
5 myfile = open('HTML/' + file)
6 fileList = myfile.readlines()
9 for line in fileList:
10 #print line
11 line = filter(lambda x: x in string.printable, line)
12 myfile.close()