Files
log-watcher/base.py

16 lines
474 B
Python
Raw Normal View History

2022-08-16 01:33:20 +00:00
from operator import itemgetter
2022-08-16 01:39:14 +00:00
# convertion of Json Data to list by selecting columns
2022-08-16 01:33:20 +00:00
state, time = list( zip(*[ (x['state'], x['last_updated']) for x in raw_data]))
# another converion thorugh itemgetter (a little faster)
state, time = list( zip( *map(itemgetter('state', 'last_updated'), raw_data) ))
2022-08-16 01:39:14 +00:00
# each
2022-08-16 01:46:20 +00:00
state = list(map(itemgetter('state'), raw_data))
2022-08-16 01:52:48 +00:00
def string_2_dict(string_as_dict):
2022-08-16 01:46:20 +00:00
from ast import literal_eval
return literal_eval(string_as_dict)