Importing METAR data from sequence of .txt-files

1 view (last 30 days)
Hi! I have some problems importing data from files that look like this:
METAR ESDF 010020Z AUTO 31003KT 230V350 9999NDV NCD 12/08 Q1017 METAR ESDF 010050Z AUTO 24003KT 230V320 9999NDV NCD 12/08 Q1017 METAR ESDF 010120Z AUTO 25003KT 230V350 9999NDV NCD 11/08 Q1017 METAR ESDF 010150Z AUTO 25005KT 230V350 9999NDV NCD 11/08 Q1017 METAR ESDF 010220Z AUTO 24005KT 230V310 9999NDV NCD 11/08 Q1017 METAR ESDF 010250Z AUTO 30003KT 230V350 9999NDV NCD 11/08 Q1017 METAR ESDF 010320Z AUTO VRB02KT 9999NDV NCD 11/08 Q1017 METAR ESDF 010350Z VRB02KT CAVOK 11/08 Q1017 METAR ESDF 010420Z 00000KT CAVOK 12/09 Q1018 METAR ESDF 010450Z 29003KT CAVOK 12/11 Q1018 METAR ESDF 010520Z 30005KT 230V350 CAVOK 13/11 Q1018
The import stops around line 6300 out of 450000. The reason is a linechange in the .txt file that is erroneous. Is there a way of blocking this line and continue with the next instead?
The next step for me is to import a sequence of these files with:
txtFiles = dir('*.txt') numfiles = length(txtFiles); mydata = cell(1, numfiles);
for k = 1:numfiles try mydata{k} = importdata(txtFiles(k).name); catch disp('error') end end
Are there any better way of importing these files?
Thank you!

Answers (1)

KSSV
KSSV on 5 Oct 2016
doc textscan

Categories

Find more on MATLAB Report Generator in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!