-
Notifications
You must be signed in to change notification settings - Fork 1
/
list_unique.py
66 lines (53 loc) · 1.39 KB
/
list_unique.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# 04 October 2018, St. Paul, MN
# Peter L. Morrell -
# Needed for arguments below
import os
import sys
Usage = """
Usage:
python inclusive_file exclusive_file out_directory
"""
if len(sys.argv) < 2:
print(Usage)
exit(1)
#####
# Defining arguments
#####
# A description of the program
DESCR = """Compare files and remove overlaps."""
# Create a new argument parser
def retain(ret):
retain_temp = []
with open(ret, 'r') as f:
for line in f:
retain_temp.append(line.strip().split())
return retain_temp
def remove(rem):
remove_temp = []
with open(rem, 'r') as f:
for line in f:
remove_temp.append(line.strip().split())
return remove_temp
def uniq_list(retain, remove):
for element in remove:
retain.remove(element)
#return list(set(retain).symmetric_difference(set(remove)))
return retain
def main(ret,rem):
retained = retain(ret)
removed = remove(rem)
#rename = ()
# temp = os.path.basename(rem)
# rename = os.path.splitext(temp)
# except:
# print('Please pass name of file that will drop lines')
# try:
# directory_name = sys.argv[3]
# print(directory_name)
# except:
# print('Please pass directory_name')
unique = []
unique = uniq_list(retained, removed)
print (unique)
main(sys.argv[1], sys.argv[2])