summaryrefslogtreecommitdiff
path: root/compile.py
blob: 01efebaae59a2e103435dfd6fd2543d5a8166775 (plain)
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
import json
import os
import sys

compiled = []

for json_file in sys.argv[1:]:
    jfile = json.load(open(json_file))
    for beer in jfile:
        year = 2000 + beer['added'][2]
        abv = beer['abv']
        ratings = beer['ratings']
        av_rating = beer['rating']
        if (ratings >= 15) and (av_rating is not None) and (abv is not None) and (year < 2021):
            compiled.append({
                'added': {
                    'year': year,
                    'month': beer['added'][0],
                    'day': beer['added'][1],
                },
                'brewery': os.path.basename(json_file).split('.')[0],
                'name': beer['name'],
                'style': beer['style'],
                'abv': abv,
                'ratings': {
                    'count': ratings,
                    'average': av_rating
                },
                'in_production': beer['in_production']
            })

print(json.dumps(compiled))