-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathanalyze.py
More file actions
40 lines (31 loc) · 793 Bytes
/
analyze.py
File metadata and controls
40 lines (31 loc) · 793 Bytes
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
import sys, datetime
def analyze(log):
bidders = {}
try:
for x in file(log):
try:
if x.strip() == '': continue
x = x.strip().split(' ')
time = x[0].split('-') + x[1].split(':')
time = datetime.datetime(*map(int,time))
if x[2] == 'click':
at,clicks = float(x[4]),int(x[6])
# onClick
lastClick = (time,at)
elif x[2] == 'bid':
name,at,clicks = x[3][1:-1],float(x[5]),int(x[7])
bidders[name] = clicks
# onBid
if name == 'qix' and lastClick:
delay = time-lastClick[0]
timeDelay = lastClick[1]-at
if abs(timeDelay) < 1:
delays.append(timeDelay)
print timeDelay
elif x[2] == 'next':
at = float(x[4])
except:
print 'Fail on line:',x
except:
pass
return {'bidders': bidders}