How can I read dat file into table/cell?
10 ビュー (過去 30 日間)
古いコメントを表示
Hello,
how can I import the attached file into MATLAB workspace to have a "normal" table and/or cell?
THANKS,
Mark
0 件のコメント
回答 (2 件)
Walter Roberson
2022 年 6 月 2 日
fileread() the entire file. textscan() the character vector with 'headerlines' to extract the number table. After that use string processing methods to pull out whatever header information you need (regexp named tokens are useful)
0 件のコメント
Star Strider
2022 年 6 月 2 日
The first 16 lines will have to be dealt with separately (this textscan call works to produce a (16x1 ) cell array of them) if they are necessary. The data will need to be parsed from them separately. (The fopen and related functions do not work with the onlilne Run feature so I cannot demonstrate them here.)
fidi = fopen('moose_file.txt', 'rt')
First16 = textscan(fidi,'%s', 16, 'Delimiter','\r\n');
fclose(fidi);
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1019580/moose_file.txt', 'HeaderLines',17)
.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Import and Export についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!