[Numpy-discussion] 'Advanced' save and restore operation
Mon Jan 23 18:45:09 CST 2012
Note sure if there's a better way, but you can do it with some custom load
and save functions:
>>> with open('f.txt', 'w') as f:
... f.write(str(x.dtype) + '\n')
... numpy.savetxt(f, x)
>>> with open('f.txt') as f:
... dtype = f.readline().strip()
... y = numpy.loadtxt(f).astype(dtype)
I'm not sure how that'd work with structured arrays though. For the dict of
parameters you'd have to write your own load/save piece of code too if you
need a clean text file.
2012/1/23 Emmanuel Mayssat <email@example.com>
> After having saved data, I need to know/remember the data dtype to
> restore it correctly.
> Is there a way to save the dtype with the data?
> (I guess the header parameter of savedata could help, but they are
> only available in v2.0+ )
> I would like to save several related structured array and a dictionary
> of parameters into a TEXT file.
> Is there an easy way to do that?
> (maybe xml file, or maybe archive zip file of other files, or ..... )
> Any recommendation is helpful.
> NumPy-Discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion