-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
79 lines (74 loc) · 1.8 KB
/
test.py
File metadata and controls
79 lines (74 loc) · 1.8 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# from osisoft.pidevclub.piwebapi.pi_web_api_client import PIWebApiClient
# client = PIWebApiClient("https://ucd-pi-iis.ou.ad3.ucdavis.edu/piwebapi", useKerberos=False, username="username", password="password", verifySsl=True)
# print(client)
from datetime import datetime as dt
collabels = [
'Num',
'UFL',
'TimeStamp',
'Year',
'Month',
'Day',
'Hour',
'Minute',
'Wifi Access Points',
'UFL Building',
'Total_Count',
'SomeNum',
'Zero'
]
weekdays = [
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun'
]
def plabel(labels, data):
for label,d in zip(labels,data):
print(f'{label} : {d:,}')
import sys
import itertools as it
days = [0] * 7
hours = [0] * 24
minutes = [0] * 6
from collections import Counter
buildings = Counter()
for counter in it.count(1):
if counter % 10000 == 0:
print(f'Checked {counter} lines. ', end='\r')
row = sys.stdin.readline()
if not row:
break
items = {}
for label,col in zip(collabels,row.split(',')):
try:
items[label] = int(col)
except ValueError:
items[label] = col
rowtime = dt(
items['Year'],
items['Month'],
items['Day'],
items['Hour'],
items['Minute'],
)
dayofweek = rowtime.weekday()
hour = rowtime.hour
minute = rowtime.minute // 10
total = items['Total_Count']
days[dayofweek] += total
hours[hour] += total
minutes[minute] += total
buildings[items['UFL Building']] += total
print(f'Checked {counter} lines.')
plabel(weekdays, days)
print()
plabel([f'{n:02}:00' for n in range(24)], hours)
print()
plabel([f'0:{n}0' for n in range(6)], minutes)
print()
for i,(build,count) in enumerate(buildings.most_common()):
print(f'{i + 1}. {build} : {count:,}')