-
Notifications
You must be signed in to change notification settings - Fork 0
/
mapper.py
65 lines (42 loc) · 1.32 KB
/
mapper.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
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python
import sys
dep=[0,0]
arr=[0,0]
deptime=[0,0];arrtime=[0,0];air=[0,0];crselap=[0,0]
actelap=[0,0]
for line in sys.stdin:
line=line.strip().split(',')
line.pop()
line=line[2:3] + line[5:8] + line[12:15] + line[18:22]
if line[2]!='' and line[2]!='DEP_TIME':
deptime[0]+=float(line[2])
deptime[1]+=1
if line[3]!='' and line[3]!='DEP_DELAY':
dep[0]+=float(line[3])
dep[1]+=1
if line[5]!='' and line[5]!='ARR_TIME':
arrtime[0]+=float(line[5])
arrtime[1]+=1
if line[6]!='' and line[6]!='ARR_DELAY':
arr[0]+=float(line[6])
arr[1]+=1
if line[7]!='' and line[7]!='CRS_ELAPSED_TIME':
crselap[0]+=float(line[7])
crselap[1]+=1
if line[8]!='' and line[8]!='ACTUAL_ELAPSED_TIME':
actelap[0]+=float(line[8])
actelap[1]+=1
if line[9]!='' and line[9]!='AIR_TIME':
air[0]+=float(line[9])
air[1]+=1
if line[0]=='OP_CARRIER_FL_NUM':
print('001',' '.join(line).strip())
else:
print(','.join(line).strip())
dep=dep[0]/dep[1];arr=arr[0]/arr[1]
deptime=deptime[0]/deptime[1]
arrtime=arrtime[0]/arrtime[1]
crselap=crselap[0]/crselap[1]
actelap=actelap[0]/actelap[1]
air=air[0]/air[1]
print('000',deptime,dep,arrtime,arr,crselap,actelap,air)