File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ import json
2
+
3
+ def read_json (in_path ):
4
+ # in_list = list()
5
+ out_list = list ()
6
+ with open (in_path , 'r' ) as f :
7
+ tmp_list = f .readlines ()
8
+ for line in tmp_list :
9
+ line = line .strip ('\n ' )
10
+ line_json = json .loads (line )
11
+ out_list .append (line_json )
12
+ return out_list
13
+
14
+ if __name__ == '__main__' :
15
+ new_all_findres = '/home/jhliu/data/Detect-data/findres-new'
16
+ old findres = '/home/jhliu/data/Detect-data/findres'
17
+ out_findres = '/home/jhliu/data/Detect-data/findres-combine'
18
+
19
+ old_json = read_json (old_findres )
20
+ new_json = read_json (new_all_findres )
21
+
22
+ hit_list = list ()
23
+ for item in old_json :
24
+ hit_str = item ['api' ] + item ['repo' ]
25
+ if hit_str in hit_list :
26
+ continue
27
+
28
+ else :
29
+ hit_list .append (hit_str )
30
+
31
+ for item in new_json :
32
+ hit_str = item ['api' ] + item ['repo' ]
33
+ if hit_str in hit_list :
34
+ continue
35
+
36
+ else :
37
+ with open (out_findres , 'a' ) as f :
38
+ f .write (json .dumps (item ))
39
+ f .write ('\n ' )
You can’t perform that action at this time.
0 commit comments