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

5 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Workspace 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