csvTextScan
Converts into a matrix texts representing separated values
Syntax
A = csvTextScan(M) A = csvTextScan(M, separator) A = csvTextScan(M, separator, decimal) A = csvTextScan(M, separator, decimal, conversion) A = csvTextScan(M, separator, decimal, conversion, substitute) A = csvTextScan(M, separator, decimal, conversion, range) A = csvTextScan(M, separator, decimal, conversion, range, substitute)
Arguments
- M
vector of strings. UTF-8 strings are supported.
- separator
a string: the column separator mark.
- decimal
a string: the decimal mark. The available values are "." or ",".
If
decimalis not[]andconversionis set tostring, the decimal conversion will be done.- conversion
"string" or "double": type of the expected output
A. With "double",any input that can't be parsed as a literal number is converted to
%nan.literal complex numbers are supported.
- range
vector of 4 decimal integers: the range of rows and columns which must be read (default range=[], meaning that all the rows and columns). Specify range using the format
[R1 C1 R2 C2]where (R1,C1) is the upper left corner of the data to be read and (R2,C2) is the lower right corner.- substitute
a m-by-2 matrix of strings, a replacing map (default = [], meaning no replacements). The first column
substitute(:,1)contains the searched strings and the second columnsubstitute(:,2)contains the replace strings. Every occurrence of a searched string in the file is replaced.- A
matrix of strings or double, with as many rows as
Mhas components:A(i,:)is the conversion result ofM(i).
Description
Given a text matrix with delimited fields, this function returns the corresponding Scilab matrix of strings or of decimal or complex numbers.
To skip an input argument and use its default value, specify [].
The default values of optional input arguments are defined by the
csvDefault function.
![]() | The |
Examples
// convert a csv string matrix to splitted string or double matrix A = ["1;3 + i"; "Nan;-Inf"] B = csvTextScan(A,';') C = csvTextScan(A,';',[],'double') // // Configure the decimal mark. Atext = [ " 1,000000000D+00; 0,000000000D+00; 2,000000000D+02; Inf; 0,000000000D+00"; " 1,000000000D+00; 1,00000000D-300; 2,000000000D+02; Inf; 0,000000000D+00"; " 1,000000000D+00; 1,00000000D-200; 2,000000000D+02; 3,15000000D+300; 1,020000000D+02"; " 9,999999999D-01; 1,00000000D-100; 2,000000000D+02; 2,960000000D+02; 1,170000000D+02"; " 1,000000000D+00; Inf;-Inf; Nan; 0,000000000D+00" ]; csvTextScan( Atext , ";" , "," )
See also
- csvRead — Read comma-separated value file
History
| Versão | Descrição |
| 5.4.0 | Function introduced. Based on the 'csv_readwrite' module. |
| 5.4.1 | If |
| 2026.1.0 |
|
| Report an issue | ||
| << csvRead | Planilhas | csvWrite >> |
