Read a CSV (Comma Separated Values) file and convert it into a cell array.
sep (a character value) changes the character used to separate two fields. The default value is a comma (,
).
prot (a character value) changes the character used to protect a string. The default is a double quote ("
).
Optional argument hl (a numeric value >= 0) is the number of headerlines to skip; negative values are ignored. If hl is equal to or larger than the total number of lines in the file, no data is read and an empty cell array is returned.
Alternatively, optional argument range can be specified as a spreadsheet-style cell range to specify a block of fields to be returned in c. If the specified column range reaches beyond the number of fields on a line, the output cell array is padded with empty string values. If the specified row range exceeds the number of lines in the file, the range is silently truncated to match the number of lines per file.
If no range argument is supplied, csv2cell assumes the first line contains column headers and the number of fields in the first line is supposed to be the number of columns in the output array. A warning is emitted then if any data line contains more fields than the header line.
Note: newline characters in fields (i.e., multi-line text fields) are not allowed.
The maximum line width of the csv file is set to 32768 characters. (This is also the theoretical maximum number of columns - 1 in the data if all fields are empty, i.e., a line containing just 32768 consecutive separators will yield 32769 empty values.)
Package: io