How to use outerjoin for multiple files
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Ngoc Nguyen
el 13 de Mayo de 2022
Comentada: Ngoc Nguyen
el 13 de Mayo de 2022
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 comentarios
Respuesta aceptada
Stephen23
el 13 de Mayo de 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)
Más respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Compiler en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!