[SciPy-user] (no subject)

BK lists@benair....
Mon Jul 23 01:51:41 CDT 2007


Hi everybody,

since I discovered scipy I am constantly using python for all my little
data handling jobs. However, there is one problem bugging me:

my data often comes in Tecplot ascii-files that contain several sets of
(float-)data. The principle file layout ist something like

TITLE = "some name"
VARIABLES = "x", "y", "z", "abc"
ZONE T="zone1", I=    65, J=    97
[float data]
ZONE T="zone2", I=    65, J=    49
[float data]
...

I open the file using infile=open("filename",'r') to read the header
information and extract the array sizes (I,J) for the first ZONE. Then I
use io.array_import.read_array(infile,lines=(0,(1,I*J))) to read the
data for the first ZONE. Then I would like to read the header for the
second zone "zone2", extract (I,J) the same way as before and read the
data for the second zone and so on. However, I get the error 
'ValueError: I/O operation on closed file'
which seems to indicate that io.array_import.read_array closed the file
object after extracting the first data set. Looking into
'array_import.py' confirmes, that the class 'ascii_stream' closes the
file-object upon destruction of the class object.

Just for testing I changed 'array_import.py' such that it keeps the file
object open if it was not opened by array_import itself. But then I had
to learn that after importing an array the cursor is not positioned
where I expected at the end of the data set, but somewhere arbitrary in
between.

Is there any way to change this behaviour? If I re-open the file I have
to search
the starting position of the next zone before reading the next data.
While this is doable it's nevertheless annoying. Can anyone tell me how
to keep the file object open after using read_array and continuing read
operations after the last data set?

Thank you!
bene



More information about the SciPy-user mailing list