I am trying to clean up a text file by removing punctuations, numbers and
etc.
I wrote this code to try removing punctuations initially :
import string
with open("uniquewords_list.txt") as f:
L = sorted(word.strip(",") for line in f for word in line.split())
out = L.translate(string.maketrans("",""), string.punctuation)
with open('testing.txt', 'w') as filehandle:
for listitem in out:
filehandle.write('%s\n' % listitem)
However I am getting an error :
out = L.translate(string.maketrans("",""), string.punctuation)
AttributeError: 'list' object has no attribute 'translate'
I looked up the error description but still not able to fix it. Suggestions ?
Also, to delete numbers and characters like
what is an efficient way to do ?