フィルターのクリア

Reading txt file with multiple headers and non-uniform data blocks

3 ビュー (過去 30 日間)
Bruno Rodriguez
Bruno Rodriguez 2017 年 11 月 10 日
回答済み: KSSV 2017 年 11 月 10 日
All,
I'm trying to read in a large text file that has several headers (always one line, different headers but all begin with letters "AL"). I've seen a few suggestions online, but these only apply to files with equally-sized blocks of data. Unfortunately, the size of such blocks varies every time for this particular file. Additionally, I want to keep each block separate from the others.
I've attached the file in a zipped folder for reference.
Any suggestions?
Thanks!

採用された回答

KSSV
KSSV 2017 年 11 月 10 日
fid = fopen('hurdat2.txt','r') ;
S = textscan(fid,'%s','delimiter','\n') ;
S = S{1} ;
fclose(fid) ;
%%GEt lines wih AL
idx = find(contains(S,'AL')) ;
iwant = cell(length(idx),1) ;
for i = 1:length(idx)-1
iwant{i} = S(idx(i)+1:idx(i+1)-1) ;
end
iwant{end} = S(idx(end)+1:end) ;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by