Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.4.0 - English

Change language to:
Français - 日本語 - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilab help >> Spreadsheet > csvDefault

csvDefault

Get or set defaults behavior for csv files.

Calling Sequence

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 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, 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 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 "off".

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

History

VersionDescription
5.4.0 Function introduced. Based on the 'csv_readwrite' module.
Report an issue
<< Spreadsheet Spreadsheet csvRead >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Mon Oct 01 17:34:57 CEST 2012