필터 지우기
필터 지우기

Cannot Read data from text file

조회 수: 4 (최근 30일)
Preeti Sar
Preeti Sar 2018년 5월 30일
댓글: Preeti Sar 2018년 5월 31일
All I want to do is read the comma separated values from the text file and skip the first header row. Can somebody please tell me what is wrong with my code? I have attached the text file. Thanks!
FileID = fopen('test.txt','r');
C = textscan(FileID,'%f','HeaderLines',1,'Delimiter',',');
fclose(FileID);
  댓글 수: 1
dpb
dpb 2018년 5월 30일
편집: dpb 2018년 5월 30일
The time entry is not a valid floating point value so the format string is wrong. Look up the '%D' descriptor for times or, more simply, use readtable instead that will do a better job parsing the file format automagically.

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

채택된 답변

KSSV
KSSV 2018년 5월 30일
FileID = fopen('data.txt','r');
C = textscan(FileID,'%s %f %f','HeaderLines',1,'Delimiter',',');
fclose(FileID);
C{1}
C{2}
C{3}

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 String Parsing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by