Import multiple .txt files
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi,
I have some text files that I want to import all at once. I am using the following code to try to import them.
files = dir(fullfile(roothpath, '*.txt'));
file_paths = fullfile({files.folder}, {files.name});
for i = 1 : numel(file_paths)
data = textread(file_paths{i}, '');
end
However, the text files have headers and I am having trouble removing them. So my question is what can I do to import them with commands to remove the header and import all the files.
Thanks.
댓글 수: 0
답변 (1개)
Chunru
2021년 7월 29일
Use "headerlines" parameter to ignore the header lines:
data = textread(file_paths{i}, format, 'headerlines', headlineNum);
댓글 수: 2
참고 항목
카테고리
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!