MATLAB: How to read a CSV file with header

csvdata importMATLAB

How I can read one CSV file with header, semicolon to separate the column and coma to float point? One example is annex. I try use the importdata, csvread and dlmread.

Best Answer

The better way was use the textscan function with ";" delimiter and after replace the "," by "." before the conversion of string to number.
fileID = fopen(filename,'r');
startRow = 10;
dataArray = textscan(fileID,'%s%s%s',inf,'Delimiter',';',...
'HeaderLines', startRow-1,'ReturnOnError', false);
fclose(fileID);
dataArray{1,2} = strrep(dataArray{1,2},',','.');
dataArray{1,3} = strrep(dataArray{1,3},',','.');