Import multiple .txt files
3 ビュー (過去 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!