William Henney wrote:
Yes, I wasn't thinking of specialized data formats. Python already has
fine support for reading, e.g., FITS files. I was thinking more along
the lines of gnuplot's support for simple ascii data tables. E.g., easy
selection of columns to plot, single blank line indicating a gap in the
plot, double blank line indicating a new dataset, etc. This is all
trivial stuff that I can easily write myself but it would be nice if it
were a part of the plotting package (PyX does this well). It's not
really a sticking point though.
scipy's read_array, while not identical to gnuplot's, isn't bad at all:
In : scipy.io.read_array?
Base Class: <type 'function'>
String Form: <function read_array at 0x4083c614>
Definition: scipy.io.read_array(fileobject, separator=None, columns=None, comment='#', lines=None, atype='d', linesep='\n', rowsize=10000, missing=0)
Return an array or arrays from ascii_formatted data in |fileobject|.
fileobject -- An open file object or a string for a valid filename.
The string can be prepended by "~/" or "~<name>/" to
read a file from the home directory.
separator -- a string or a tuple of strings to indicate the column
separators. If the length of the string tuple is less
than the total number of columns, then the last separator
is assumed to be the separator for the rest of the columns.
columns -- a tuple of integers and range-tuples which describe the
columns to read from the file. A negative entry in the
last column specifies the negative skip value to the end.
Example: columns=(1, 4, (5, 9), (11, 15, 3), 17, -2)
will read [1,4,5,6,7,8,11,14,17,19,21,23,...]
If multiple arrays are to be returned, then this argument
should be an ordered list of such tuples. There should be
one entry in the list for each arraytype in the atype list.
lines -- a tuple with the same structure as columns which indicates
the lines to read.
comment -- the comment character (line will be ignored even if it is
specified by the lines tuple)
linesep -- separator between rows.
missing -- value to insert in array when conversion to number fails.
atype -- the typecode of the output array. If multiple outputs are
desired, then this should be a list of typecodes. The columns
to fill the array represented by the given typecode is
determined from the columns argument. If the length of atype
does not match the length of the columns list, then, the
smallest one is expanded to match the largest by repeatedly
copying the last entry.
rowsize -- the allocation row size (array grows by this amount as
data is read in).
Output -- the 1 or 2d array, or a tuple of output arrays of different
types, sorted in order of the first column to be placed
in the output array.