<< DI_show dataint Deprecated >>

dataint >> dataint > DI_writedat

DI_writedat

Writes numerical data stored in a matrix to a text or Excel file interactively.

Syntax

[exitID] = DI_writedat(dataMat)
[exitID] = DI_writedat(dataMat, path)

Arguments

dataMat:

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=error codes, see below.

Description

Write a Scilab matrix of doubles to a CSV or other text-based file or an Excel file (*.xls, '.xlsx) interactively.

To select the format, specify the corresponding file extension to the file name. E.g. *.xlsx for XML Excel 2010-365 or *.csv for data text files. Empty file extentions are not allowed.

Any file extension other than *.xls or *.xlsx is interpreted as a text file extension and creates test files. This applies not only to *.csv, *.dat, or *.txt file extensions.

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.

dataMat:

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 no file will be created. To handle errors in a script you can evaluate exitID's error codes (negative numbers):

  • 0: Everything is OK. File was created

  • -1: User canceled file selection

  • -2: User canceled parameter dialog box

  • -3: Cannot write file

Export Parameter Text Files

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 identifies 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).

Export Parameter Excel Files

Sheet no. or name:

The number or name of the worksheet of the Excel file you want to export to. "1" gets to "Sheet 1", "2" to "Sheet 2". The name of sheet should be committed without quotation marks. If left blank, "Sheet 1" is set.

Start cell:

Specify a start cell (e.g. D7). All data will be written starting from this cell. If left blank, the data will start from cell A1.

When writing to an existing file, only the specified portion is overwritten. The entire file is not rewritten, even if the operating system reports that it is. Writing to an existing file is not recommended!

Examples

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

See also

Authors


Report an issue
<< DI_show dataint Deprecated >>