Extract pickle-loading function
This commit is contained in:
parent
ded341a59b
commit
dd402ed1ce
2 changed files with 26 additions and 18 deletions
20
tracetools_analysis/analysis/load.py
Normal file
20
tracetools_analysis/analysis/load.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
import pickle
|
||||
|
||||
|
||||
def load_pickle(pickle_file_path):
|
||||
"""
|
||||
Load pickle file containing converted trace events.
|
||||
|
||||
:param pickle_file_path (str): the path to the pickle file to load
|
||||
:return list(dict): the list of events (dicts) read from the file
|
||||
"""
|
||||
events = []
|
||||
with open(pickle_file_path, 'rb') as f:
|
||||
p = pickle.Unpickler(f)
|
||||
while True:
|
||||
try:
|
||||
events.append(p.load())
|
||||
except EOFError:
|
||||
break # we're done
|
||||
|
||||
return events
|
Loading…
Add table
Add a link
Reference in a new issue