How can I read dat file into table/cell?
조회 수: 9 (최근 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!