Scilab Home page | Wiki | Bug tracker | Forge | Mailing list archives | ATOMS | File exchange
Please login or create an account
Change language to: English - Français - Português - 日本語 -
Справка Scilab >> Электронная таблица > csvTextScan

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, range)

Parameters

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 decimal is not [] and conversion is set to string, 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.

A

matrix of strings or double, with as many rows as M has components: A(i,:) is the conversion result of M(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 csvTextScan and csvRead functions have the same purpose. csvTextScan input are strings, while csvRead reads from a file.

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

ВерсияОписание
5.4.0 Function introduced. Based on the 'csv_readwrite' module.
5.4.1 If decimal is not [] and conversion is set to string, the decimal conversion will be done.
Scilab Enterprises
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Thu Feb 14 15:05:26 CET 2019