Get or set defaults for csv files.
allvalues = csv_default()
value = csv_default(field)
bRes = csv_default(field, value)
a 6-by-2 matrix of strings, the values of all the fields. The first column contains the available fields, while the second column contains the current values.
a 1-by-1 matrix of strings, the name of the field to get or set.
The available values of field
are "separator",
"decimal", "conversion", "precision", "regexp", "eol".
a 1-by-1 matrix of strings, the value of the field to get or set.
a 1-by-1 matrix of booleans, bRes is true if the value was correctly set, bRes is wrong is the value was not correct.
This function allows to quiery or configure the options of the csv files. These options are used by the read and write function when the user does not specify them in the calling sequence.
The allvalues = csv_default()
calling sequence returns
the value of all the fields.
The value = csv_default(field)
calling sequence returns
the value corresponding to the given field.
The bRes = csv_default(field, value)
calling sequence
allows to set the value of the given field.
If the function cannot set the field to the given value, then bRes
is false.
In this case, the value of the field is unchanged.
If the function is able to change the field to the given value,
then bRes
is true.
The available fields are the following.
field = "separator": the separator of the columns of the csv files. Default separator = ",".
field = "decimal": the decimal point used in the csv files. The available values are "." or ",". Default decimal = ".".
field = "conversion": the type of the output of the csv_read
function.
Possible values are "string" or "double".
Default conversion = "double".
If conversion = "string", then the csv_read
function returns a matrix of strings.
If conversion = "double", then the csv_read
function returns a matrix of doubles.
field = "precision": the C format used to create the strings from the doubles in the
csv_write
function.
The default value is precision="%.17lg"
.
This format allows to perform write-read error-free cycles.
This means that we can save a double into a .csv, then read the double and
get the exact same value.
The supported format is: %type or %[width].[precision]type.
type: lf, lg, d, i, e, f, g
width: Optional number that specifies the minimum number of characters output.
precision: Optional number that specifies the maximum number of characters printed for all or part of the output field, or the minimum number of digits printed for integer values.
field = "regexp": regular expression used to extract comments of the csv_read
function.
by default, this value is '' (no regexp).
field = "eol": end of line used to write lines of the csv_write
function.
Possible values are "linux", "windows", "macos9".
by default, this value is platform-dependant.
Copyright (C) 2010-2011 - DIGITEO - Allan CORNET
Copyright (C) 2011 - DIGITEO - Michael Baudin