i am reading a file .txt, now I wanna remove duplicate words.
c = collections.Counter()
with open('DatoSO.txt', 'rt') as f:
for line in f:
c.update(line.split())
for palabra,count in c.most_common():
if count > 1 :
with open('DatoSO.txt', 'rt') as f:
Here REMOVE
I dont know How remove word from file
You can’t remove content from a file and have the remaining content shifted down. You can only append, truncate or overwrite.
Your best option is to read the file in to memory, process it in memory and then write it back to disk.