Grant Edwards wrote: > On 2008-09-30, Peter Pearson <[EMAIL PROTECTED]> wrote: >> On Tue, 30 Sep 2008 00:04:18 +0200, Ivan Rebori wrote: >>> 1. Multi dimensional arrays - how do you load them in python >>> For example, if I had: >>> ------- >>> 1 2 3 >>> 4 5 6 >>> 7 8 9 >>> >>> 10 11 12 >>> 13 14 15 >>> 16 17 18 >>> ------- >>> with "i" being the row number, "j" the column number, and "k" the .. >>> uhmm, well, the "group" number, how would you load this ? >>> >>> If fortran90 you would just do: >>> >>> do 10 k=1,2 >>> do 20 i=1,3 >>> >>> read(*,*)(a(i,j,k),j=1,3) >>> >>> 20 continue >>> 10 continue >>> >>> How would the python equivalent go ? > > You would drag yourself out of the 1960s, install numpy, and > then do something like this: > > a = read_array(open("filename.dat","r")) > >> Since you're coming from the FORTRAN world (thank you for that >> stroll down Memory Lane), you might be doing scientific >> computations, and so might be interested in the SciPy package >> (Google scipy), which gives you arrays and matrices. Don't >> expect to be able to use it without learning some Python, >> though. > > If not full-up scipy (which provides all sorts of scientific > and numerical-analysis stuff), then at least numpy (which > provides the basic array/matrix operations: > > http://numpy.scipy.org/ > > Though the software is free, the documentation isn't. You've > got to buy the book if you want something to read. IMO, it's > definitely worth it, and a good way to support the project even > if you don't really need something to keep your bookends apart. clip ... The book is free now, as of Aug 21, 08. http://www.tramy.us/guidetoscipy.html
Paul Probert -- http://mail.python.org/mailman/listinfo/python-list