I have txt files in russian which i need to read and trim out all the special characters like !,digits, blankspaces and write it into another file in the encoded form.
Below is the code i am using for
for fname in filelist:
if fname.endswith('.txt'):
count = 0
path = os.path.join(dirs, fname)
os.chmod(dirs, 0755)
txtfile = file('%s/%s.txt' % (dir, fname), 'w', 'utf-8')
textf = codecs.open("%s/%s" % (dirss,fname), 'r', "utf-8")
p = re.compile("[^a-z A-Z]")
lines = textf.readlines()
for line in lines:
s2 = p.sub("", line)
txtfile.write(s2)
count +=1
if count <= count1:
continue
if count == count1:
break
textf.close()
txtfile.close()
When i execute the above code it gives me an error TypeError: an integer is required
I am working with multiple lanaguges of txt files.
Please help