-
Notifications
You must be signed in to change notification settings - Fork 0
Get results
Puerto Pablo edited this page Sep 20, 2017
·
3 revisions
Import Redis and open connection with results data base container linked to host port 6379.
import redis
r = redis.StrictRedis(host='localhost', port=6379, db=0)
I wrote some code allowing to retrieve data following a pattern:
def get_data_from_pattern(pattern, pref='OUT'):
list_of_keys = [key for key in r.keys(pref + '*' + pattern + '*') if 'time' not in str(key)]
list_of_time = [key for key in r.keys(pref + '*' + pattern + '*time')]
res = {key.decode("utf-8").replace(pref + '_', ''): list(map(float, r.lrange(key, 0, -1))) for key in list_of_keys}
time = {key.decode("utf-8").replace(pref + '_', '').replace('_time', ''): list(map(float, r.lrange(key, 0, -1))) for key in list_of_time}
return res, time
You can use it like this:
results_th, times_th = get_data_from_pattern('*sup*')