Read and display the first 25 or an arbitrary number of lines of a text data file.
[dataMat] = DI_show() [dataMat] = DI_show(path) [dataMat] = DI_show(path, n) [dataMat] = DI_show(,n) [dataMat, exitID] = DI_show() [dataMat, exitID] = DI_show(path) [dataMat, exitID] = DI_show(path, n) [dataMat, exitID] = DI_show(, n)
string, target path for the file selector (OPTIONAL)
integer, Number of lines to display (OPTINAL), default: 25
string, name of the matrix which stores the imported data, if confirmed, default: ans, IMPORTANT: See note below.
integer, exit codes, 0=OK, -1, -2, -3, -4=error codes, if data reading was confirmed. IMPORTANT: See note below.
Read the first 25 or an arbitrary number of lines of a text-based data file and displays them in the console for reviewing data, determine delimiter signs, comment lines etc. This makes it easier to fill in the right paramezters for reading procedures, as DI_read().
In the GUI the user will be prompted whether he or she wants to load the data into a matrix variable after the preview was displayed. If the user committed the question the reading procedure DI_read() will be called in the background.
You can commit an optional target 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.
You can commit an optional number of lines to display. If you do not specify N 25 lines will be displayed by default.
This is the name of the matrix variable which will contain the imported data for further processing in Scilab's console or in a script. It is available when you confirm data reading in the GUI only.
The exitID gives a feedback what happened inside the function. If something went wrong dataMat is always [] (empty). To handle errors in a script you can evaluate exitID's error codes (negative numbers):
0: Everything is OK. Matrix dataMat was created
-1: User canceled file selection
-2: User canceled parameter dialog box
-3: Cannot read or interpret data file
-4: Cannot interpret file correctly - maybe header present (only CSV/TXT data files)
They will be available when you confirm data reading in the GUI only.
![]() | Only available if reading was confirmed in the GUI. |
Read text-based data files which contains numerical data. The following field delimiters are accepted: Comma, semicolon, space(s), tabular(s). The decimal delimiter can be point or comma.
![]() | Note that the file has to be correctly formated. All rows have to have the
same number of columns. |
Import Parameter:
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). Text-based data files has a space or spaces as delimiters. E.g. to specify a tabulator as separator, type in the word "tab", for a space separator the word "space" without quotes.
The character which identifies the decimal place. In general CSV files it is the point (.), in most European ones it is the comma (,).
The number of lines to be ignored at the beginning of the file. This is useful to skip table headers.
The row/column at which the import is going to start. Type a number. 1 means import starts at row/column 1 inclusively.
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.
For CSV and text-based data files there are different prerequisites to consider.
All rows have to have the same number of columns. That does not mean that every cell has to be occupied by a number. Only the separator has to be present:
2.3 , 4.4 , 7.6 , 9.5 5.6 , 6.9 , ,
Strings or missing data (see above) are represented as Nan (not-a-number) in the matrix. E.g.:
2.3 4.4 7.6 9.5 5.6 6.9 Nan Nan
All rows have to have the same number of columns and should not contain strings (text). Otherwise the data will be imported as a string matrix and not a number matrix.
| 2.3 4.4 7.6 9.5 | | | | 5.6 6.9 |