How I can read a CSV file with header?

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.

 Akzeptierte Antwort

Hildo
Hildo am 25 Nov. 2016

0 Stimmen

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},',','.');

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 20 Jun. 2015

0 Stimmen

[a,b,c]=xlsread('PV-20150616.csv')
out=b(8:end,:)

Produkte

Gefragt:

am 18 Jun. 2015

Beantwortet:

am 25 Nov. 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by