How to combine multiple tables from diffrent folders and save as on table?

5 ビュー (過去 30 日間)
Tomaszzz
Tomaszzz 2022 年 3 月 9 日
回答済み: Voss 2022 年 3 月 11 日
Hi all,
I have 20 folders with mutiple mat files which are 1 x 1 structures with a 1 x 54 table.
I managed to list all folders and all files. I can also load each mat files in a loop as below.
for k = 1:numel(file_list)
if isempty(file_list{k})
continue
end
disp(file_list{k}.name)
A = fullfile(topLevelFolder,subFolders(k).name,file_list{k}.name);
data = load(A);
end
Now, I want to consecutively save each table with an end result a single 20x54 table (mat or csv) . For example:
End table:
Row 1: row 1 from table 1
Row 2: row 1 from table 2
Row 3: row 1 table 3
and so on
Can you help please?

採用された回答

Voss
Voss 2022 年 3 月 11 日
t = {};
for k = 1:numel(file_list)
if isempty(file_list{k})
continue
end
disp(file_list{k}.name)
A = fullfile(topLevelFolder,subFolders(k).name,file_list{k}.name);
data = load(A);
t{end+1} = data.your_table_in_A;
end
t = vertcat(t{:});

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by