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))