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

9 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

Voss
Voss el 11 de Mzo. de 2022
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{:});

Más respuestas (0)

Categorías

Más información sobre Workspace Variables and MAT-Files en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by