Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
csvDefault
Get or set defaults behavior for csv files.
Syntax
allvalues = csvDefault() value = csvDefault(field) bRes = csvDefault(field, value)
Parameters
- allvalues
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.
- field
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", "encoding", "blank".- value
a 1-by-1 matrix of strings, the value of the field to get or set.
- bRes
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.
Description
This function allows to query 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 syntax.
The allvalues = csvDefault()
syntax
returns the value of all the fields.
The value = csvDefault(field)
syntax
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
csvRead
function. Possible values are "string" or "double". Default conversion = "double". If conversion = "string", then thecsvRead
function returns a matrix of strings. If conversion = "double", then thecsvRead
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 isprecision="%.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
csvRead
function.by default, this value is '' (no regexp).
field = "eol": end of line used to write lines of the
csvWrite
function.Possible values are "linux", "windows", "macos9".
by default, this value is platform-dependent.
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
History
Версия | Описание |
5.4.0 | Function introduced. Based on the 'csv_readwrite' module. |
5.4.1 | 'blank' is enabled by default. |
Report an issue | ||
<< Электронная таблица | Электронная таблица | csvRead >> |