-
Notifications
You must be signed in to change notification settings - Fork 0
/
reducer.py
53 lines (37 loc) · 970 Bytes
/
reducer.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
#!/usr/bin/env python
import sys
c=0
for line in sys.stdin:
if c<1:
mean=line.strip().split()[1:]
for i in range(len(mean)):
mean[i]=float(mean[i])
c+=1
elif c==1:
cols=line.strip().split()[1:]
cols.pop(6)
cols.append('RESULT')
print(','.join(cols).strip())
c+=1
else:
line=line.strip().split(',')
if line[2]=='':
line[2]=str(mean[0])
if line[3]=='':
line[3]=str(mean[1])
if line[5]=='':
line[5]=str(mean[2])
if line[6]=='':
line[6]=str(mean[3])
if line[7]=='':
line[7]=str(mean[4])
if line[8]=='':
line[8]=str(mean[5])
if line[9]=='':
line[9]=str(mean[6])
a=line.pop(6)
if float(a)>15:
line.append('1')
else:
line.append('0')
print(','.join(line).strip())