[SciPy-User] [scipy-user] How to use genfromtext() with np.array?
Paul Anton Letnes
Tue Feb 7 08:38:01 CST 2012
The easiest way is probably savetxt/loadtxt:
In : d = np.linspace(0,1,10)
In : np.savetxt('foo', d)
In : d2 = np.loadtxt('foo')
In : d-d2
Out: array([ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])
It should work equally well with 2D arrays.
On 7. feb. 2012, at 11:43, Fabien Lafont wrote:
> I've saved a np.array in a file using write(). Ihave then a file with
> my np.array over 8 columns and I can't load it using genfromtext to
> load at the same time the entire array. It seems genfromtext doesn't
> "see" the array as a real array but as 8 different columns. Is it
> possible to load the array easily with genfromtext, or save my array
> in a different way. It works with a for loop over each indices of the
> array with + "\n" but it's not very convenient.
> SciPy-User mailing list
More information about the SciPy-User