<< DI_readxls dataINT Utilities >>

dataINT >> dataINT > DI_writecsv

DI_writecsv

Exports numerical data stored in a matrix variable to a CSV file interactively

Calling Sequence

[exitID] = DI_writecsv(csvMat)
[exitID] = DI_writecsv(csvMat, path)

Parameters

csvMat:

a string, name of the matrix variable you want to store in a file

path:

a string, target path for the file selector (OPTIONAL)

exitID:

an integer, exit codes, 0=OK, -1, -2, -3, -4=error codes, see below.

Description

Write a Scilab matrix of doubles to a CSV or other text-based file interactively.

path:

You can commit an optional path to the function. This is used to open the file selector at the committed target path. If you omit it your home directory is set as the target path.

csvMat:

This is the name of the matrix variable which contents the data you want to export.

exitID:

The exitID gives a feedback what happened inside the function. If something went wrong csvMat is always [] (empty). To handle errors in a script you can evaluate exitID's error codes (negative numbers):

  • 0: Everything is OK. Matrix csvMat was created

  • -1: User canceled file selection

  • -2: User canceled parameter dialog box

  • -3: Cannot write CSV file

  • -4: No matrix variable name specified

Export Parameter:

Field Separator:

This is the character which separates the fields and numbers, resp. In general CSV-files it is the comma (,), in European ones it is often the semicolon (;). Sometimes it is a tabulator (tab) or a space (space). E.g. to specify a tabulator as the separator, type in the word "tab" without quotes.

If you select space just ONE space character delimits the data.

Decimal separator:

The character which indentifies the decimal place. In general CSV files it is the point (.), in most European ones it is the comma (,).

Comment header:

Place a comment in the first line/row of the file. This is useful to describe your data. Just one line is supported (OPTIONAL).

Examples

dat = [32.4 34.6 36.5 32.6 ; 102.4 105.0 104.8 102.6];
// Open the file selector at the currend directory
// and write matrix "dat" to the specified csv-file
[exitID] = DI_writecsv("dat", pwd());
disp("Exit-code: " + string(exitID)) // Displays exit code

See also

Authors


Report an issue
<< DI_readxls dataINT Utilities >>