-
Notifications
You must be signed in to change notification settings - Fork 15
/
findrubbishusr.py
44 lines (44 loc) · 1.02 KB
/
findrubbishusr.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
import codecs;
usrt={};
usrc={};
usrl={};
usraptme={};
usr=[];
go=[];
with open('fork.txt') as f:
for line in f:
line=line.replace('\n',''); # VERY IMPORTANT !!!
if line != '': #avoid empty l n e
usraptme[line]=0;
usr.append(line);
usrt[line]=0;
usrc[line]=0;
usrl[line]=0;
#bld fork usr lst
print('finish loading');
#print(usr);
i=1;
with open('train.txt') as f:
for line in f:
if line != '':
name= line.split('\t')[0];
if name in usr:
print('find '+str(i));
i=i+1;
usraptme[name]=usraptme[name]+1; #add
split=line.split('\t');
usrt[name]=int(usrt[name])+int(split[3]);
usrc[name]=int(usrc[name])+int(split[4]);
usrl[name]=int(usrl[name])+int(split[5]);
count=1;
for user in usr:
if (int(usrt[user])/int(usraptme[user])) < 2:
if (int(usrc[user])/int(usraptme[user])) < 2:
if (int(usrl[user])/int(usraptme[user])) < 2:
print(count);
count=count+1;
go.append(user);
with codecs.open('rubbishuser.txt','a','utf8') as c:
for goal in go:
c.write(goal+'\n');
#by DGideas