[Numpy-discussion] how to save a large array into a file quickly
Eric Firing
efiring at hawaii.edu
Tue Oct 14 21:29:32 EDT 2008
frank wang wrote:
> Hi,
>
> I have a large ndarray that I want to dump to a file. I know that I can
> use a for loop to write one data at a time. Since Python is a very
> powerfully language, I want to find a way that will dump the data fast
> and clean. The data can be in floating point or integer.
Use numpy.save for a single array, or numpy.savez for multiple ndarrays,
assuming you will want to read them back with numpy. If you want to
dump to a text file, use numpy.savetxt. If you want to dump to a binary
file to be read by another program, you might want to use the tofile
method of the ndarray.
Eric
More information about the NumPy-Discussion
mailing list