how to skip incomplete and missing lines when reading from Text file?
이전 댓글 표시
Hi everyone. I have some trouble. I try reading from a text file and sample data is as shown
16.Mrz.14 10:12:34
16.Mrz.14 10:12:37 -01,22522E-09
16.Mrz.14 10:12:40 -00,90903E-09
16.Mrz.14 10:12:42 -00,72633E-09
16.Mrz.14 10:12:45 -00,59084E-09
16.Mrz.14 10:12:48 -00,50685E-09
16.Mrz.14 10:12:50 -00,42215E-09
16.Mrz.14 10:13:00 -00,25394E-09
16.Mrz.14 10:13:03 +9,900000E+37OADC,+1629586.578736secs,+12454976RDNG#
16.Mrz.14 10:13:22
16.Mrz.14 10:13:31 -000,1151E-09
This is the code for reading from text file
%% Open the text file.
fileID = fopen(fullPath,'r');
%% Read columns of data according to format string.
dataArray = textscan(fileID, formatSpec, 'Delimiter','', 'WhiteSpace', '', 'ReturnOnError', false);
%% Close the text file.
fclose(fileID);
I used text scan and it gives me an error. Sometimes there are also empty lines btw these lines. I want to skip these incomplete lines and missing lines.how to do it? I would be glad if someone helps me.
채택된 답변
추가 답변 (1개)
Jos (10584)
2014년 3월 18일
0 개 추천
Empty lines are skipped. The real trouble is reading the incomplete lines. I suggest to read each line in as a string, and then parse those strings in a loop.
카테고리
도움말 센터 및 File Exchange에서 Data Type Conversion에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!