Hi,

I work with text files which contain several arrays separated by a few 
lines of other information, for example:

POINTS 4 float
-5.000000e-01 -5.000000e-01 0.000000e+00
5.000000e-01 -5.000000e-01 0.000000e+00
5.000000e-01 5.000000e-01 0.000000e+00
-5.000000e-01 5.000000e-01 0.000000e+00

CELLS 2 8
3 0 1 2
3 2 3 0

(yes, that's the legacy VTK format, but take it just as an example)

I have used custom Python code with loops to read similar files, so the 
speed was not too good. Now I wonder if it would be possible to use the 
numpy.loadtxt() function for the "array-like" parts. It supports passing 
an open file object in, which is good, but it wants to read the entire 
file, which does not work in this case.

It seems to me, that an additional parameter to loadtxt(), say "nrows" or 
"numrows", would do the job, so that the function does not try reading the 
entire file. Another possibility would be to raise an exception as it 
is now, but also to return the data succesfully read so far.

What do you think? Is this worth a ticket?

r.
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to