Skip to content

Instantly share code, notes, and snippets.

@AlgorithmAlchemy
Last active May 26, 2022 23:08
Show Gist options
  • Save AlgorithmAlchemy/aa0002e4d8a0830243363a5c0e42fffc to your computer and use it in GitHub Desktop.
Save AlgorithmAlchemy/aa0002e4d8a0830243363a5c0e42fffc to your computer and use it in GitHub Desktop.
Txt file duoble deleter python.py
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