Skip to content

Instantly share code, notes, and snippets.

@OlegKorn
Created November 23, 2024 11:12
Show Gist options
  • Save OlegKorn/64f5b278d0c999030b1f509a362106fb to your computer and use it in GitHub Desktop.
Save OlegKorn/64f5b278d0c999030b1f509a362106fb to your computer and use it in GitHub Desktop.
clear dublicated items from a file
import logging
file_dirty = "G:/Desktop/Emails/Cyprus/ccs.org.cy.txt"
def clear():
FORMAT = '%(message)s'
logging.basicConfig(
filename=f"G:/Desktop/Emails/Cyprus/{file_dirty.split('/')[-1]}_clear.txt",
level=logging.INFO,
format=FORMAT
)
clear = []
f_dirt = open(file_dirty, 'r').readlines()
for i in f_dirt:
if not i.strip() in clear:
clear.append(i.strip())
for i in clear:
logging.info(i)
clear()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment