[SciPy-User] [scipy-user] How to use genfromtext() with np.array?

Fabien Lafont lafont.fabien at gmail.com
Tue Feb 7 09:39:41 EST 2012


Thank you very much, it works perfectly!



2012/2/7 Paul Anton Letnes <paul.anton.letnes at gmail.com>:
> The easiest way is probably savetxt/loadtxt:
> In [1]: d = np.linspace(0,1,10)
>
> In [2]: np.savetxt('foo', d)
>
> In [3]: d2 = np.loadtxt('foo')
>
> In [4]: d-d2
> Out[4]: array([ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.])
>
> It should work equally well with 2D arrays.
>
> Paul
>
> 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.
>>
>> Thx,
>>
>> Fabien
>> _______________________________________________
>> SciPy-User mailing list
>> SciPy-User at scipy.org
>> http://mail.scipy.org/mailman/listinfo/scipy-user
>
> _______________________________________________
> SciPy-User mailing list
> SciPy-User at scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user



More information about the SciPy-User mailing list