In a small data-acquisition project we use the Python\'s pickle to store recorded data, i.e. for each \"event\" we add it to the output file f with
pickle
f
Yes, indeed. Use this generator below to make the events readable in a loop:
def pickleLoader(pklFile): try: while True: yield pkl.load(pklFile) except EOFError: pass
Now you can simply write:
with open(filename) as f: for event in pickleLoader(f): do_something()