-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcount_tune_stats.py
41 lines (29 loc) · 1.15 KB
/
count_tune_stats.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
import argparse
import json
from collections import defaultdict
def load_from_json(raw_json: str):
return json.loads(raw_json)
#TODO: Max size of raw JSON?
#TODO: More clever object representation of tunes? (not sure if I want that yet)
def main(filename: str):
with open(filename, 'r') as tunesfile:
#TODO: Max size of raw JSON?
tunes_json = tunesfile.read()
tune_list = load_from_json(tunes_json)
tune_type = defaultdict(int)
tune_time = defaultdict(int)
tune_mode = defaultdict(int)
# Note that this includes multiple settings of the same tune
for tune in tune_list:
tune_type[tune['type']] += 1
tune_time[tune['meter']] += 1
tune_mode[tune['mode']] += 1
print(tune_type)
print(tune_time)
print(tune_mode)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Count up some stats about tunes")
parser.add_argument("--jsonfile", dest='tunefile',
help='File to load tune list from')
args = parser.parse_args()
main(args.tunefile)