Sorry you don't have to transpose the matrix...
Youngung Jeong On Thu, May 12, 2011 at 7:30 PM, Youngung Jeong <youngung.je...@gmail.com>wrote: > Hello, > > Use np.loadtxt > > >>> a = np.loadtxt(filename) ##in case no rows to skip. > >>> a = a.transpose() ##in your case, I guess you should > transpose it.. > > > > Youngung Jeong > > > > > On Thu, May 12, 2011 at 7:21 PM, Claudia Chan Yone < > chanyone.clau...@gmail.com> wrote: > >> Hi, >> >> I have a problem with the Numpy module, but I think it is a very basic >> issue >> for many of you... >> I have a file with numerical data (2 columns, and 5 lignes) as : >> 1 2 >> 3 4 >> ... ... >> >> And I woulid like to convert it in a matrix as : >> [[1,2] >> [3,4] >> ...] >> >> My python script is : >> >> fic=open('file.txt','r') >> ligne=fic.readlines() >> fic.close() >> >> m=numpy.array(ligne) >> >> and I get : >> ['1,2\n' '3,4'] >> >> So I cannot call m[0][0]... >> >> Even if I modify my text file with : >> [[1,2], >> [3,4] >> ...] >> >> I get : >> >> ['[[1,2],[3,4]]'] and I cannot call m[0][0]. >> >> Thank you very much for your help, >> >> >> Clo >> >> _______________________________________________ >> NumPy-Discussion mailing list >> NumPy-Discussion@scipy.org >> http://mail.scipy.org/mailman/listinfo/numpy-discussion >> >> >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion