how to skip incomplete and missing lines when reading from Text file?
Mostra commenti meno recenti
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.
Risposta accettata
Più risposte (1)
Jos (10584)
il 18 Mar 2014
0 voti
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.
Categorie
Scopri di più su Whos in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!