[SciPy-user] scipy.io.write_array and the precision

Ryan Krauss ryanlists at gmail.com
Thu Apr 6 09:32:12 EDT 2006


I see this as well:
mymat=rand(3,3)

In [5]: mymat
Out[5]:
array([[ 0.19463406,  0.92311955,  0.18562841],
       [ 0.31952113,  0.42110699,  0.91320285],
       [ 0.2302922 ,  0.04191094,  0.13106267]])

mymat.tofile('mymat.txt',sep='\t') or sep=' ' produces a file with
only one line.

In [11]: mat2=scipy.io.read_array('mymat.txt')

In [12]: mat2
Out[12]:
array([ 0.19463406,  0.92311955,  0.18562841,  0.31952113,  0.42110699,
        0.91320285,  0.2302922 ,  0.04191094,  0.13106267])

In [13]: shape(mat2)
Out[13]: (9,)

So, how do you read these back in without knowing their shape ahead of time?

Ryan

On 4/6/06, jaonary at free.fr <jaonary at free.fr> wrote:
> Selon Travis Oliphant <oliphant.travis at ieee.org>:
>
> > arr.tofile('myfile.txt',sep=' ')
> >
> > will do it...
> >
>
> Thank your for your answer. In fact, with arr.tofile() things go well, there's
> just one more litte problem. With this method (tofile) my array is written in
> one line. How can I do to put one row in one line ? Also, where can I find more
> information on these built-in method in the array object and related stuff ?
> It tried something like this :
> help(numpy.array.tofile)
> but there's nothing and so on the web sit.
> It seems that the documentation on numpy is difficult to find :-)
>
> Jaonary
>
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user
>




More information about the SciPy-User mailing list