-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcomp_result.py
31 lines (28 loc) · 1004 Bytes
/
comp_result.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
def read_file(filename):
result = {}
with open(filename, 'r') as file:
for line in file:
key, value = line.strip().split(',', 1)
result[key] = value
return result
def join_files(sap_file, ares_file, comb_file, output_file):
sap_data = read_file(sap_file)
ares_data = read_file(ares_file)
comb_data = read_file(comb_file)
with open(output_file, 'w') as file:
for key in comb_data:
sap_value = sap_data.get(key, 'NONE')
ares_value = ares_data.get(key, 'NONE')
#comb_value = comb_data[key]
if sap_value == 'NONE':
sap_value = 'NONE,NONE,NONE'
if ares_value == 'NONE':
ares_value = 'NONE,NONE,NONE'
line = f"{key},{sap_value},{ares_value}\n"
file.write(line)
# Example usage:
sap_file = 'sap.txt'
ares_file = 'ares.txt'
#comb_file = 'comb.txt'
output_file = 'comp_result.txt'
join_files(sap_file, ares_file, output_file)