-
Notifications
You must be signed in to change notification settings - Fork 1
/
dupcheck.py
42 lines (34 loc) · 895 Bytes
/
dupcheck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sys
# Using readlines()
file1 = open(str.strip(sys.argv[1]), 'r')
Lines = file1.readlines()
filetext1=""
duplines=[]
uniqlines=[]
linenum=0
linecount=[]
# Strips the newline character
for line in Lines:
filetext1=line.strip()
file2 = open(str.strip(sys.argv[2]), 'r')
Lines1 = file2.readlines()
linenum=linenum+1
# Strips the newline character
for line2 in Lines1:
filetext2=line2.strip()
if filetext1==filetext2:
duplines.append(filetext1)
linecount.append(linenum)
newline=[]
print("Duplicate Lines found: "+str(len(linecount)))
linenum=0
for line in Lines:
linenum=linenum+1
if linenum in linecount:
pass
else:
newline.append(str.strip(line))
for line in newline:
f = open("newlines.txt", "a")
f.write(line+"\n")
f.close()