summaryrefslogtreecommitdiff
path: root/compile.py
blob: cb421b5af38c293c5446c1b666e769d7b1eee9db (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
import json
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]
        month = beer['added'][0]
        brewery = json_file.split('.')[0]
        name = beer['name']
        style = beer['style']
        abv = beer['abv']
        ratings = beer['ratings']
        av_rating = beer['rating']
        if (ratings >= 15) and (av_rating is not None) and (abv is not None):
            compiled.append({
                'year': year,
                'month': month,
                'brewery': brewery,
                'name': name,
                'style': style,
                'abv': abv,
                'ratings': ratings,
                'average': av_rating
            })

print(json.dumps(compiled))