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 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