I collected data in the form of list of lists and wrote the data into a text file. The data in the text file looks like
[[123231,2345,888754],[223467,85645]
You could just pickle your data instead. To save it:
>>> import pickle
>>> p= [[123231,2345,888754],[223467,85645]]
>>> with open("data.txt", "wb") as internal_filename:
... pickle.dump(p, internal_filename)
To load it:
>>> with open("data.txt", "rb") as new_filename:
... pp = pickle.load(new_filename)
>>> pp
[[123231, 2345, 888754], [223467, 85645]]
This is also useful for much more elaborate objects.