How I can read a CSV file with header?

15 vues (au cours des 30 derniers jours)
Hildo
Hildo le 18 Juin 2015
Réponse apportée : Hildo le 25 Nov 2016
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.
  1 commentaire
Star Strider
Star Strider le 18 Juin 2015
Use the xlsread function if you have Excel.

Connectez-vous pour commenter.

Réponse acceptée

Hildo
Hildo le 25 Nov 2016
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},',','.');

Plus de réponses (1)

Azzi Abdelmalek
Azzi Abdelmalek le 20 Juin 2015
[a,b,c]=xlsread('PV-20150616.csv')
out=b(8:end,:)

Catégories

En savoir plus sur Large Files and Big Data dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by