|
rdcols
|
cols = rdcols(f)
or cols = rdcols(f, ncols)
eq_nocopy, col1, *cols(1)
eq_nocopy, col2, *cols(2)
...
eq_nocopy, colN, *cols(ncols)
cracks ascii file F into NCOLS columns, returning an array of
pointers to the columns. A "column" is defined by either its
width in characters, or by the appearance of a delimiting
character (such as a blank, a comma, or a tab). Multiple
delimiting characters may either be skipped (as usual if the
character is a blank), or may represent a number of empty
columns (as for reading a typical text file exported from a
spreadsheet or database program).
rdcols returns an array of pointers COLS, with *COLS(i) the
contents of the i-th column. The NCOLS parameter may be omitted
in which case rdcols will guess the number of columns.
F may be either a file handle or a filename.
nskip=m skip the first M lines of the file (M=0 by default)
nlines=n read only the first M+N lines of the file
comment=text interpret lines beginning with TEXT (possibly preceded
by blanks) as comments (blank lines are always comments)
width=w column width, or list of widths (w=0 means any width)
delim=d column delimiters (as for strtok), or list of delimiters
type=t column type, or list of types
t=0 means guess, t=1 means string, t=2 means integer, t=3 means real,
t=4 means either integer or real
marker=k marker column delimiters (as for strtok)
missing=m missing value, or list of values
for empty numeric columns
The width=, delim=, type=, and missing= keywords may either be scalar
values to apply to every column, or lists to apply to successive
columns. The marker= keyword is similar to the delim= keyword,
except that multiple consecutive occurrences indicate empty
columns. If any list is shorter than NCOLS, its final value
applies to all remaining columns. If any list is longer than
NCOLS, its trailing values are silently ignored.
By default, width=0. Non-zero width is very tricky, since a
column begins wherever the previous column ended; if the previous
column had width=0, its delimiter is treated as a part of it, so
it is not included in the width count. Consequently, the width=
keyword is best suited to situations in which only the final
width value is 0.
By default, marker=[]. If present, then every column is delimited
by a character in marker, and every occurrence of such a character
indicates a new column. Use marker="\t" to read tab-delimited text
files exported from a spreadsheet or database program. Non-zero
width= values supersede marker=, but delim= is ignored if marker
is present.
By default, delim=" \t", and type=0, so that blanks and tabs delimit
columns, and rdcols guesses whether a column contains string or
numeric data. A numeric column ends at the first character that
cannot be interpreted as part of the number, whether or not that is
a character in delim. If you use type= to force a numeric column,
empty rows or rows which are not numbers get the value 0.0 by
default, or the value specified by the missing= keyword. Missing
values in string columns always get the value "".
If you need finer control of the returned types than provided by
the type= keyword, see rdconvert.
|