<< DI_readcsv dataINT DI_writecsv >>

dataINT >> dataINT > DI_readxls

DI_readxls

Imports a binary Excel file (xls) in a matrix variable interactively

Calling Sequence

[xlsMat] = DI_readxls()
[xlsMat] = DI_readxls(path)
[xlsMat, exitID] = DI_readxls()
[xlsMat, exitID] = DI_readxls(path)

Parameters

path:

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

xlsMat:

a string, name of the matrix which stores the imported data

exitID:

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

Description

Read data from a binary Excel 95-2003 file (*.xls) and stores it into a matrix variable interactively.

DI_readxls does not handle data from XML-based Excel files (*.xlsx) of Excel 2007 and higher!

DI_readxls handles numerical data only. Strings or missing data are imported as Nan (Not-a-number, %nan).

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.

xlsMat:

This is the name of the matrix variable which contents the imported data for further processing in Scilab's console or in a script.

exitID:

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

  • 0: Everything is OK. Matrix xlsMat was created

  • -1: User canceled file selection

  • -2: User canceled parameter dialog box

  • -3: Cannot read or interpret XLS file

Import Parameter:

Sheet#:

The number of the sheet of the Excel file you want to import from. The names of the sheets are not evaluated. The 1st sheet is 1 the 2nd is 2 independent of their names in Excel.

Row/Columns Range Start:

The row/column at which the import is going to start. Type a number. 1 means import starts at row/column 1 inclusively.

Row/Columns Range End:

The row at which the import is going to end. Type a number or $ (dollar- sign). 12 means the import stops at row 12 inclusively, $ means that all rows/columns are read to the end.

Examples

[mat, id] = DI_readxls(fullfile(DI_getpath(), "demos")) // Read XLS file
disp("Exit-ID: "+string(id),mat,"data:") // Displays imported data "mat" and exit code "id"
if id == 0 then // Plot data if import was sucessful
plot(mat(:,1),mat(:,14),".-")
xtitle("Central England Temperature","Year","Mean Temperature [°C]")
end

See also

Authors


Report an issue
<< DI_readcsv dataINT DI_writecsv >>