merge two csv files with a key

6 次查看(过去 30 天)
alpedhuez
alpedhuez 2020-6-10
评论: alpedhuez 2020-6-11
I have two csv files. One file has date and temperature. Anothe file has date and rainfall. I want to combine two files using date as a key. Please advise.

回答(1 个)

Anish Walia
Anish Walia 2020-6-11
Assuming files are names file1 and file 2
table1 = readtable('file1.csv');
table2 = readtable('file2.csv');
%variable name of the column to use as key to join should be same in both tables (data in your case)
mergedTable = join(table1,table2);
% mergedTable contains the combined table
writetable(mergedTable,'MergedTables.csv');

类别

Help CenterFile Exchange 中查找有关 Downloads 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by