-
Notifications
You must be signed in to change notification settings - Fork 0
/
#timepark.py#
67 lines (60 loc) · 2.11 KB
/
#timepark.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
1 import datetime as dt
2 filename = 'revenue-transaction-report-2012-a.csv'
3 f = open ( filename,'r')
4 lines = f.readlines()
5 initial = True
6 exittime = 0
7 entrytime = 0
8 numrecords = len(lines) - 1
9 totaltimespentparked = dt.timedelta(weeks=0, days=0, hours=0, minutes=0)
10 for i,line in enumerate(lines):
11 if initial:
12 initial = False
13 else:
14 myline = line.split(',')
15 entry = myline[0]
16 if entry:
17 entrytime = dt.datetime.strptime(entry, '%m/%d/%y %H:%M')
18 exittime = dt.datetime.strptime(myline[1], '%m/%d/%y %H:%M')
19
20 totaltimespentparked = totaltimespentparked + (exittime - entrytime)
21 # print totaltimespentparked
22
23 print "Seconds parked"
24 print totaltimespentparked.seconds + totaltimespentparked.days*86400
25 print "Days:",totaltimespentparked.days
26 ave = (totaltimespentparked.days*86400 + totaltimespentparked.seconds/60) / numrecords
27 print ave
28
29
30 print "Records: " + str(numrecords)
31
32 print "Minutes: " + str(totaltimespentparked.days)
33
34import datetime as dt
filename = 'revenue-transaction-report-2012-a.csv'
f = open ( filename,'r')
lines = f.readlines()
initial = True
exittime = 0
entrytime = 0
numrecords = len(lines) - 1
totaltimespentparked = dt.timedelta(weeks=0, days=0, hours=0, minutes=0)
for i,line in enumerate(lines):
if initial:
initial = False
else:
myline = line.split(',')
entry = myline[0]
if entry:
entrytime = dt.datetime.strptime(entry, '%m/%d/%y %H:%M')
exittime = dt.datetime.strptime(myline[1], '%m/%d/%y %H:%M')
totaltimespentparked = totaltimespentparked + (exittime - entrytime)
# print totaltimespentparked
print "Seconds parked"
print totaltimespentparked.seconds + totaltimespentparked.days*86400
print "Days:",totaltimespentparked.days
ave = (totaltimespentparked.days*86400 + totaltimespentparked.seconds/60) / numrecords
print ave
print "Records: " + str(numrecords)
print "Minutes: " + str(totaltimespentparked.days)