error detection when reading in text
Ältere Kommentare anzeigen
I have a long file of which this is a typical sample
11-Aug-2015 102.3
12-Aug-2015 103.4
14-Aug-2015 101.7
15-Aug-2015 102.1
21-Aug-2015 102.8
23-Aug-2015 102.6
What is the easiest way to read in data like this, with error detection. Suppose for example (as happened to me recently) the fullstop in the middle of one of the numbers is mistakenly replaced by a comma. Or there could be some other obvious error in the format of the data file. I would like the script to tell me at least the line number on which the error occurs. Here are the relevant lines from the script that I would like to improve, in particular replacing textread by something else, since textread is now deprecated:
[cellfiledate,fileweight]=textread('DataFile','%s %f');
dnumsFile=datenum(cellfiledate,'dd-mmm-yyyy');
Should I use textscan? Thanks for any help.
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Large Files and Big Data finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!