I have a CSV file with the following content:
Header line1
Space
Space
Space
,1,2,3,
1,81,82,83
And I am trying to read the data portion into a numeric matrix. Here is the code I have implemented, however I am having issues.
%To get the number of rows in the file
for i = 1:9
headerline = fgetl(fid);
headerline = strsplit(headerline,',')
end
fclose(fid);
fopen(fid);
% to get the data
C = textscan(fid,'%s','headerline',4,'EmptyValue',=Inf)
rowsize = size(C{1});
data = []
% to store data in matrix
for i = 1:rowsize
data = [data, strsplit(C{1}{i},',')];
end
Can anybody recommend a better way to just read the whole file into a numeric matrix? Thanks!