Add files via upload
This commit is contained in:
commit
7627d479a1
1 changed files with 41 additions and 0 deletions
41
no doublon.py
Normal file
41
no doublon.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
from tkinter import *
|
||||
from tkinter import filedialog
|
||||
|
||||
class Nodoublon:
|
||||
|
||||
def suppressionDoublon(self, file):
|
||||
l = []
|
||||
with open(file) as f:
|
||||
for line in f:
|
||||
l.append(line.replace("\n",""))
|
||||
l2 = []
|
||||
for e in l:
|
||||
if l.count(e) < 2:
|
||||
l2.append(e)
|
||||
|
||||
|
||||
with open(f"{file.replace('.txt','')}-convert.txt", "w") as f:
|
||||
for e in l2:
|
||||
f.write(f"{e}\n")
|
||||
return
|
||||
|
||||
|
||||
def getfile(self):
|
||||
self.filename = filedialog.askopenfilename()
|
||||
|
||||
def start(self):
|
||||
fenetre = Tk()
|
||||
fenetre.title("Supression des Doublons totale")
|
||||
fenetre.geometry("150x50")
|
||||
|
||||
|
||||
bouton_getfiles = Button(fenetre, text="Get Files", command=self.getfile)
|
||||
bouton_getfiles.pack()
|
||||
|
||||
bouton_go = Button(fenetre, text="Go!", command=lambda: self.suppressionDoublon(self.filename))
|
||||
bouton_go.pack()
|
||||
|
||||
fenetre.mainloop()
|
||||
|
||||
if __name__ == '__main__':
|
||||
Nodoublon().start()
|
Reference in a new issue