csvDefaultGet or set defaults behavior for csv files.Calling Sequenceallvalues = csvDefault() value = csvDefault(field) bRes = csvDefault(field, value) Parametersallvaluesa 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.
fielda 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",
"encoding", "blank".
valuea 1-by-1 matrix of strings, the value of the field to get or
set.
bResa 1-by-1 matrix of booleans, bRes is true if the value was
correctly set, bRes is wrong is the value was not correct.
DescriptionThis 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 = csvDefault() calling sequence
returns the value of all the fields.
The value = csvDefault(field) calling sequence
returns the value corresponding to the given field.
The bRes = csvDefault(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
csvReadfunction. Possible values are "string" or
"double". Default conversion = "double". If conversion = "string",
then the csvRead function returns a matrix of
strings. If conversion = "double", then the
csvRead function returns a matrix of
doubles.
field = "precision": the C format used to create the strings
from the doubles in the csvWrite 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, gwidth: 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 csvReadfunction.
by default, this value is '' (no regexp).field = "eol": end of line used to write lines of the
csvWritefunction.
Possible values are "linux", "windows", "macos9".by default, this value is platform-dependant.field = "encoding":Possible values are "utf-8", "iso-latin".by default, this value is "utf-8".field = "blank": remove all blank lines before to parse
text
Possible values are "on", "off".by default, this value is "on".Examples// See all the available fields
allvalues = csvDefault()
// Get the value of the "precision" field
value = csvDefault("precision")
// Set the value of the "precision" field
bRes = csvDefault("precision","%.17e") // Expected = %t
// Set the value of the "precision" field to
// an impossible value
bRes = csvDefault("precision","Ouch!") // Expected = %f
See Also
csvRead
csvWrite
History5.4.0Function introduced. Based on the 'csv_readwrite' module.5.4.1'blank' is enabled by default.