Name

read_csv — Read comma-separated value file

Calling Sequence

M = read_csv(fname [,sep])

Parameters

fname

a character string. The file path.

sep

a character string. Field separator used, default value is ","

M

a matrix of strings.

Description

Given an ascii file with delimited fields, for instance created by a spreadsheet using "Text and comma" format, read_csv(fname) returns the corresponding Scilab matrix of strings. Use read_csv(fname,sep) for another choice of separator.

Note: You may eval all or part of M using function evstr in order to convert string variables into numeric variables.

Examples

// create a file with some data separated with tab    
A = 1:50;
mputl(strcat(string(A),ascii(9)), TMPDIR + '/foo.csv');

// read csv file
B = read_csv(TMPDIR + '/foo.csv');

// eval B
C = evstr(B);

// compares original data and result
and(A == C)

See Also

write_csv, evstr

Authors

Allan CORNET