Created
November 23, 2024 11:12
-
-
Save OlegKorn/64f5b278d0c999030b1f509a362106fb to your computer and use it in GitHub Desktop.
clear dublicated items from a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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