[Numpy-discussion] greedy loadtxt
Christopher Barker
Chris.Barker at noaa.gov
Thu Mar 27 15:25:06 EDT 2008
lorenzo bolla wrote:
> The problem with fromfile() is that it doesn't know anything about ndarrays.
> If my file is a table of ncols and nrows, fromfile() will give me a
> 1darray with nrows*ncols elements, while loadtxt() will give me a
> 2dmatrix nrows x ncols. In other words, I loose the "shape" of the table.
yup -- you need to know something about the shape. It also doesn't
support comments, and all sorts of other stuff. It is, however, very
fast. I mostly use it to read more complex file formats, ones that first
tell you haw many numbers there are, then have the numbers. It works
great for that.
hmm-- I wonder how hard it would be to special case linefeeds (from
other white space) in fromfile(), and have it figure out the shape from
that?
-CHB
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the NumPy-Discussion
mailing list