<< csv_stringtodouble CSV read write files csv_write >>

CSV read write files >> CSV read write files > csv_textscan

csv_textscan

Read comma-separated value in a matrix of strings

Calling Sequence

A = csv_textscan(M)
A = csv_textscan(M, separator)
A = csv_textscan(M, separator, decimal)
A = csv_textscan(M, separator, decimal, conversion)
A = csv_textscan(M, separator, decimal, conversion, range)

Parameters

M

a m-by-1 or 1-by-m matrix of strings.

separator

a 1-by-1 matrix of strings, the column separator mark.

decimal

a 1-by-1 matrix of strings, the decimal mark. The available values are "." or ",".

conversion

a 1-by-1 matrix of strings, the type of the output A. Available values are "string" or "double".

range

a 1-by-4 or 4-by-1 matrix of floating point 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

a m-by-n matrix of strings or double.

Description

Given an ascii file with delimited fields, this function returns the corresponding Scilab matrix of strings or doubles.

The csv_textscan function has the same purpose as csv_read, except that csv_textscan reads in a string, while csv_read reads in a file.

The default value of the optional input arguments are defined by the csv_default function.

Any optional input argument equal to the empty matrix [] is set to its default value.

When input argument "conversion" is equal to "double", strings are converted as NaN.

Examples

// convert a csv string matrix to splitted string or double matrix
A = ["1;3 + i"; "Nan;-Inf"]
B = csv_textscan(A,';')
C = csv_textscan(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"
];
csv_textscan( Atext , ";" , "," )

See Also

Authors

Copyright (C) 2010-2011 - DIGITEO - Allan CORNET

Copyright (C) 2011 - DIGITEO - Michael Baudin

<< csv_stringtodouble CSV read write files csv_write >>