reading csv file from 10 th line ?

조회 수: 1 (최근 30일)
E
E 2019년 7월 27일
편집: E 2019년 7월 28일
i create function read file line by line but after first 10 th line another function will read
so how i can start from 10 th line?
while(i ~=9)
i = i + 1;
next_line = fgetl(fid);
D=c1;
c1=cell2mat(textscan(next_line,'%f %f %f %f','Delimiter', ',','CollectOutput', true))
c1=[D;c1]
end
thanks

답변 (1개)

newbie9
newbie9 2019년 7월 27일
If you want to read only the 10th line:
mydata10only = textscan(fid001, '%f %f %f %f', 1 , 'HeaderLines', 10);
mydata10only = [mydata10only{:}]; % this unpacks the cell array
fclose(fid001)
If you want to read in everything after the 9th line:
mydata_notneeded = textscan(fid001, '%f %f %f %f', 1 , 'HeaderLines', 9);
mydata9plus = textscan(fid001, '%f %f %f %f');
mydata9plus = [mydata9plus{:}]; % this unpacks the cell array
fclose(fid001)
clear mydata_notneeded
  댓글 수: 1
E
E 2019년 7월 27일
편집: E 2019년 7월 27일
thanks so much
i want to read file after 10 th line
"line by line" not all lines
i use fgetl as part from while loop
while(i ~=9)
i = i + 1;
next_line = fgetl(fid);
D=c1;
c1=cell2mat(textscan(next_line,'%f %f %f %f','Delimiter', ',','CollectOutput', true))
c1=[D;c1]
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