How to use outerjoin for multiple files
1 回表示 (過去 30 日間)
古いコメントを表示
Could anyone please help me to solve this problem:
I have 5 files
file1.CSV (key1,var1)
file2.CSV (key1,var2)
file3.CSV (key1,var3)
file4.CSV (key1,var4)
file5.CSV (key1,var5)
How to use outerjoin for 5 files?
Thank you very much!
0 件のコメント
採用された回答
Stephen23
2022 年 5 月 13 日
fnm = compose("file%d.csv",1:5);
tbl = readtable(fnm(1));
tbl.Properties.VariableNames = {'Key1','Var1'};
for k = 2:numel(fnm)
tmp = readtable(fnm(k));
tmp.Properties.VariableNames = {'Key1',sprintf('Var%d',k)};
tbl = outerjoin(tbl,tmp, 'MergeKeys',true);
end
display(tbl)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で MATLAB Compiler についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!