-
Notifications
You must be signed in to change notification settings - Fork 0
/
Document_comparer.py
49 lines (32 loc) · 1.17 KB
/
Document_comparer.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
43
44
45
46
47
48
# 20-11-2018 | THILINA_CHATHURANGA @ Hostel
# Read first file, line at a time.
# Read second file and search for above string inside it.
# If found ignore, else write them to aseperate file.
# 24-10-2018 | THILINA_CHATHURANGA @ Campus
import codecs
import re
import os
file1 = "D:\\Education\\Z\\Filtered\\1CONCATENATED\\CONJOINED_ADJECTIVES__UNIQUE_SET.TXT"
file2 = "D:\\Education\\Z\Filtered\\1CONCATENATED\\old\\old conj adj\\CONJOINED_ADJECTIVES__UNIQUE_SET_mannually_sorted.TXT"
def compare_line(file1_line):
with codecs.open(file2, encoding="utf-8") as fp2:
flag = 0
file2_line = fp2.readline()
if file2_line.__eq__(file1_line):
# print(file1_line + " " + file2_line)
flag = 1
while file2_line:
file2_line = fp2.readline()
if file2_line.__eq__(file1_line):
flag = 1
break
if flag == 0:
print(file1_line.split('\r\n')[0])
def read_file():
with codecs.open(file1, encoding="utf-8") as fp:
line = fp.readline()
compare_line(line)
while line:
line = fp.readline()
compare_line(line)
read_file()