Last active
May 26, 2022 23:08
-
-
Save AlgorithmAlchemy/aa0002e4d8a0830243363a5c0e42fffc to your computer and use it in GitHub Desktop.
Txt file duoble deleter python.py
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 re | |
from tkinter import Tk | |
from tkinter.filedialog import askopenfilename | |
Tk().withdraw() | |
filepath = askopenfilename() | |
users_list = list() | |
# код для удаления из текстовика лишней инфы | |
with open(filepath, "r+") as f: | |
lines = f.readlines() | |
for i in lines: | |
if str(i).replace("\n", "") not in "None": # убираем пустые столбцы | |
if str(i).replace("\n", "") in users_list: | |
continue | |
users_list.append("@" + str(i).replace("\n", "").replace("@","")) | |
f.close() | |
with open(filepath, "w+") as f: | |
lines = f.readlines() | |
for i in users_list: | |
if i is not None: | |
f.write(i + "\n") | |
f.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment