-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpseudo.py
41 lines (38 loc) · 991 Bytes
/
pseudo.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
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 31 17:05:04 2019
@author: smartdsp
"""
with open('webcam_list.txt','r') as f1:
f_c = f1.readlines()
filename = []
for j in f_c:
filename.append(j[:-3])
dic_target = {}
with open('pre_and_sim.txt','r') as f:
f_context = f.readlines()
count = 0
for i in f_context:
dic_target.setdefault(eval(i.split(' ')[0]),[]).append([eval(i.split(' ')[1]),filename[count]])
count += 1
class_c = 0
result = []
for k in range(31):
if k not in dic_target:
continue
ans = sorted(dic_target[k],reverse = True)
if 0 < len(ans) <= 3:
for t in ans:
result.append(t[1] + ' ' + str(k))
else:
for t in range(3):
result.append(ans[t][1] + ' ' + str(k))
with open('amazon_list.txt','r') as fs:
source = fs.readlines()
with open('a_with_pseudo.txt','w') as fn:
for i in source:
fn.write(i)
for j in result:
fn.write(j+'\n')
print('ok')