Data
Assume the following data format (with a header line in the first row, 500+ rows):
1, "<LastName> ,<Title>. <FirstName>", <Gender>, 99.9
My Code
I've tried this (IGNORE: see edit below):
[flag, name, gender, age] = textread('file.csv', '%d %q %s %f', 'headerlines', 1);
The Error
...and get the following error message
error: textread: A(I): index out of bounds; value 1 out of bound 0
error: called from:
error: C:\Program Files\Octave\Octave3.6.2_gcc4.6.2\share\octave\3.6.2\m\io\textread.m at line 75, column 3
Questons:
- Is my format string incorrect given the text qualifier (and the comma embedded in the "name" string)?
- Am I even using the correct method of loading a CSV into MATLAB\Octave?
EDIT
I forgot the delimiter (error message returns failure on different line in strread.m):
[flag, name, gender, age] = textread('file.csv', '%d %q %s %f', 'headerlines', 1, 'delimiter', ',');
dlmread? mathworks.com/help/matlab/ref/dlmread.html orcsvread? mathworks.com/help/matlab/ref/csvread.html - Dan