Skip to content Skip to sidebar Skip to footer

Cpickle Class With Data Save To File

I've big class in Python it's 'DataBase-like' class. I want to save it to file - all including data. This is input(example to show the issue, in script database is like 10000 recor

Solution 1:

You are pickling "DataBase" which is a class definition. You need to instantiate an object of class DataBase then pickle that.

objDataBase = DataBase()
objDataBase.Arrays.Data = etc....

filename='D:/results/file.lft'
file=open(filename,'w')
cPickle.dump(objDataBase, file, protocol=2)
file.close()

Post a Comment for "Cpickle Class With Data Save To File"