Working with SondeHub Data - projecthorus/sondehub-infra GitHub Wiki
Sorting JSON Exported data
JSON data exported from SondeHub Grafana dashboards is provided as an array of objects (e.g. [ {}, {}. {} ]
), but these objects will very likely be out of order. Sorting them for further analysis can be performed in a few ways.
Assuming you have downloaded JSON data to 'data.json':
Command-Line using JQ:
cat data.json | jq -r 'sort_by(.datetime)' > sorted.json
Python:
import json
f = open('data.json', 'r')
data = json.loads(f.read())
data_sorted = sorted(data, key=lambda t: t['datetime'])