[sage-devel] Re: loading integer or float data from file into a matrix

2008-01-10 Thread Harald Schilly
On Jan 10, 5:42 pm, myFalc <[EMAIL PROTECTED]> wrote: > At the moment I'm trying to load a file into sage and put its data > into a matrix. a more general question, at the top of the sage notebook on the left is the "data" dropdown menu. what exactly does it? also including a matrix or just a g

[sage-devel] Re: loading integer or float data from file into a matrix

2008-01-10 Thread Fernando Perez
On Jan 10, 2008 10:59 AM, <[EMAIL PROTECTED]> wrote: > > numpy saves the day. > > import numpy > A = numpy.loadtxt('foo.data') #A is a float array > B = M.astype(int) #B is an int array > > M = Matrix(RDF, list(A)) #M is a RDF matrix > N = Matrix(ZZ, list(B))#N is an I

[sage-devel] Re: loading integer or float data from file into a matrix

2008-01-10 Thread boothby
numpy saves the day. import numpy A = numpy.loadtxt('foo.data') #A is a float array B = M.astype(int) #B is an int array M = Matrix(RDF, list(A)) #M is a RDF matrix N = Matrix(ZZ, list(B))#N is an Integer matrix On Thu, 10 Jan 2008, David Roe wrote: > One way to d

[sage-devel] Re: loading integer or float data from file into a matrix

2008-01-10 Thread David Roe
One way to do it is to use the Python functions on strings. For example, if you want to use the real double field (RDF) and matrix_data is your string, the following should do what you want: M = matrix(RDF, [b.split() for b in matrix_data.split('\n')]) The split method of a string creates a list