[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
62.1 Introduction to numericalio | ||
62.2 Definitions for numericalio |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
numericalio
is a collection of functions to read and write data files.
The entire file is read to construct one object;
partial reads are not supported.
It is assumed that each item to read or write is atomic: an integer, float, bigfloat, string, or symbol, and not a rational or complex number or any other kind of nonatomic expression. These functions may attempt to do something sensible faced with nonatomic expressions, but the results are not specified here and subject to change.
Atoms in both input and output files have the same format as
in Maxima batch files or the interactive console.
In particular, strings are enclosed in double quotes,
backslash \
prevents any special interpretation of the next character,
and the question mark ?
is recognized at the beginning of a symbol
to mean a Lisp symbol (as opposed to a Maxima symbol).
No continuation character (to join broken lines) is recognized.
separator_flag tells which character separates elements. It is an optional argument for all read and write functions.
For input, these values of separator_flag are recognized:
comma
for comma separated values,
pipe
for values separated by the vertical bar character |
,
semicolon
for values separated by semicolon ;
,
and space
for values separated by space or tab characters.
If the file name ends in .csv
and separator_flag is not specified,
comma
is assumed.
If the file name ends in something other than .csv
and separator_flag
is not specified,
space
is assumed.
For output, the same four flags are recognized as for input,
and also tab
, for values separated by the tab character.
In input, multiple successive space and tab characters count as a single separator.
However, multiple comma, pipe, or semicolon characters are significant.
Successive comma, pipe, or semicolon characters (with or without intervening spaces or tabs)
are considered to have false
between the separators.
For example, 1234,,Foo
is treated the same as 1234,false,Foo
.
In output, false
atoms are written as such;
a list [1234, false, Foo]
is written 1234,false,Foo
,
and there is no attempt to collapse the output to 1234,,Foo
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Reads the file file_name and returns its entire content as a matrix. If separator_flag is not specified, the file is assumed space-delimited.
read_matrix
infers the size of the matrix from the input data.
Each line of the file becomes one row of the matrix.
If some lines have different lengths, read_matrix
complains.
read_lisp_array
requires that the array
be declared by make_array
before calling
the read function. (This obviates the need to infer the array
dimensions, which could be a hassle for arrays with multiple dimensions.)
read_lisp_array
does not check to see that the
input file conforms in some way to the array dimensions; the input
is read as a flat list, then the array is filled using fillarray
.
read_maxima_array
requires that the array
be declared by array
before calling
the read function. (This obviates the need to infer the array
dimensions, which could be a hassle for arrays with multiple dimensions.)
read_maxima_array
does not check to see that the
input file conforms in some way to the array dimensions; the input
is read as a flat list, then the array is filled using fillarray
.
read_hashed_array
treats the first item on a line as a
hash key, and associates the remainder of the line (as a list) with the key.
For example,
the line 567 12 17 32 55
is equivalent to A[567]: [12, 17, 32, 55]$
.
Lines need not have the same numbers of elements.
read_nested_list
returns a list which has a sublist for each
line of input. Lines need not have the same numbers of elements.
Empty lines are not ignored: an empty line yields an empty sublist.
read_list
reads all input into a flat list.
read_list
ignores end-of-line characters.
write_data
writes the object X to the file file_name.
write_data
writes matrices in row-major form,
with one line per row.
write_data
writes Lisp and Maxima declared arrays in
row-major form, with a new line at the end of every slab.
Higher-dimensional slabs are separated by additional new lines.
write_data
writes hashed arrays with a key followed by
the associated list on each line.
write_data
writes a nested list with each sublist on one line.
write_data
writes a flat list all on one line.
Whether write_data
appends or truncates its output file
is governed by the global variable file_output_append
.
[ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
This document was generated by Robert Dodier on May, 2 2007 using texi2html 1.76.