How to use outerjoin for multiple files
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Stephen23
le 13 Mai 2022
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)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur MATLAB Compiler dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!