Writes numerical data stored in a matrix to a text or Excel file interactively.
[exitID] = DI_writedat(dataMat) [exitID] = DI_writedat(dataMat, path)
name of the matrix variable you want to store in a file
a string, target path for the file selector (OPTIONAL)
an integer, exit codes, 0=OK, -1, -2, -3=error codes, see below.
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.
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.
This is the name of the matrix variable which contents the data you want to export.
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
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.
The character which identifies the decimal place. In general CSV files it is the point (.), in most European ones it is the comma (,).
Place a comment in the first line/row of the file. This is useful to describe your data. Just one line is supported (OPTIONAL).
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.
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! |