How I can read a CSV file with header?

조회 수: 15 (최근 30일)
Hildo
Hildo 2015년 6월 18일
답변: Hildo 2016년 11월 25일
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
Star Strider
Star Strider 2015년 6월 18일
Use the xlsread function if you have Excel.

댓글을 달려면 로그인하십시오.

채택된 답변

Hildo
Hildo 2016년 11월 25일
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},',','.');

추가 답변 (1개)

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

카테고리

Help CenterFile Exchange에서 Large Files and Big Data에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by