import configparser
import os
import sys
+from collections import defaultdict
from flask import Flask, render_template, jsonify, request
import flask.json
from sqlalchemy import create_engine
format = request.args.get('format', 'default')
if format == 'c3':
- c3result = dict()
+ c3result = defaultdict(list)
for row in result:
- if not row['sensor_id'] in c3result:
- c3result[row['sensor_id']] = list()
c3result[row['sensor_id']].append(row['value'])
- if not row['sensor_id'] + '_x' in c3result:
- c3result[row['sensor_id'] + '_x'] = list()
dt = row['timestamp'].strftime('%Y-%m-%d %H:%M:%S')
c3result[row['sensor_id'] + '_x'].append(dt)
result = c3result