summaryrefslogtreecommitdiff
path: root/compile.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2021-01-19 12:16:26 +0100
committeremkael <emkael@tlen.pl>2021-01-19 12:16:26 +0100
commit0cad52070819091c04eea364673c9c3c7a043bf3 (patch)
tree0f15a5e9bd3ab999526caef38a3ee8acd63fe024 /compile.py
Data retrieval scripts
Diffstat (limited to 'compile.py')
-rw-r--r--compile.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/compile.py b/compile.py
new file mode 100644
index 0000000..cb421b5
--- /dev/null
+++ b/compile.py
@@ -0,0 +1,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))