diff options
Diffstat (limited to 'app/main/datasets.py')
| -rw-r--r-- | app/main/datasets.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/app/main/datasets.py b/app/main/datasets.py new file mode 100644 index 0000000..c06b4bf --- /dev/null +++ b/app/main/datasets.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +import os +import json + +from flask import current_app + + +def load_data_for_chart(name): + dataset_dir = os.path.join( + current_app.instance_path, current_app.config["DATASET_DIR"] + ) + target_filename = os.path.join(dataset_dir, name + ".json") + with open(target_filename, 'rb') as fid: + data = json.load(fid) + chart_data = [{"value": x} for x in data['series']['V1']['raw']] + return {"chart_data": chart_data} + + |
