[SciPy-dev] Input value from data file to 2D array
Thu Apr 17 22:23:57 CDT 2008
I'm a newbie of python and scipy, numpy and
try to rewriting the Fortran77 code to Python.
First, here is my Fortran code.
DIMENSION A(10,10), B(10,10)
DO 10 K=1,2
and aaa.dat file is
0 1 1
1 1 1
2 1 1
; ; ;
; ; ;
18 1 1
19 1 1
The code is going to read each value of the data file(aaa.dat)
and input the value to the array A, B. According the "DO 10 K=1,2"
which means a loop of Fortran it is going to try to read 1st 2x3 array
and set them to A, also read 2nd 2x3 array to B.
Two "WRITE(6,1602) "s mean that the final value of array A and B are
3rd 2x3 array adn 4th 2x3 array
4 1 1
5 1 1
6 1 1
7 1 1
Question 1: How to input value from data file to 2D array ?
Can I write code like following ?
for i in range(1,2):
for j in range(1,3):
(If the size of data file is very big , using
read_array() or fromfile() will be very hard. )
Question 2: Such like "DO 10 K=1,1500", I just read a part of
data file(<=very big file). How cat write this with Python ?
Any advice please!
More information about the Scipy-dev