-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcount_sntc.py
64 lines (49 loc) · 1.6 KB
/
count_sntc.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
import csv
import operator
import json
csv_file = open('sntc.csv', 'r')
csv_reader = csv.DictReader(csv_file)
products = {}
# products_list = []
software_versions = {}
for row in csv_reader:
# if '3.6.6E' in row['SW Version']:
# if 'FOC1912X1BV' in row['Serial Number']:
#print(row['Product ID'])
product = row['Product ID']
# if product not in products_list:
# products_list.append(product)
software = row['SW Version']
if product not in products:
products[product] = {}
if 'count' not in products[product]:
products[product]['count'] = 1
else:
products[product]['count'] = products[product]['count'] + 1
#print(row)
if software:
if software not in products[product]:
products[product][software] = 1
else:
products[product][software] = products[product][software] + 1
# if software in software_versions:
# software_versions[software] = software_versions[software] + 1
# else:
# software_versions[software] = 1
#products['WS-C3750X-24T-S'] = 1
#print(products_list)
print(json.dumps(products, indent=4))
#print(software_versions)
# sorted_d = sorted(products.items(), key=operator.itemgetter(1),reverse=True)
# for key, value in sorted_d:
# print(key,value)
# {
# 'AIR-CAP1602E-A-K9': {
# "13.3" : 2,
# "15.6" : 6
# },
# 'AIR-LAP1242AG-A-K9': {
# "12.16" : 5,
# "3.6" : 7
# }
# }