Combining excel files with unequal rows
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I have two excel files which I would like to combine into a single file. The data is as follows
:![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1664521/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1664521/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1664526/image.jpeg)
I would like to combine these two tables into a single table with the columns "Name" "Date" "Value 1" "Value2" where the occassion of John 04-05-2011 shows a value for Value 1 but remains empty for Value 2.
0 Commenti
Risposta accettata
Dyuman Joshi
il 9 Apr 2024
Modificato: Dyuman Joshi
il 9 Apr 2024
%Data from the images attached for example
%Use readtable() to read the data as tables directly
Name = ["Adam" "Adam" "John" "John" "John" "Karen"].';
Date = datetime(2010, [11 12 11 12 5 5], [5 6 5 6 4 4]).';
Value1 = [12 16 8 3 14 12].';
t1 = table(Name, Date, Value1)
Name = ["Adam" "Adam" "John" "John" "Karen"].';
Date = datetime(2010, [11 12 11 12 5], [5 6 5 6 4]).';
Value2 = [8 6 1 3 8].';
t2 = table(Name, Date, Value2)
%join tables
out = outerjoin(t1, t2, 'Keys', [1 2])
4 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Spreadsheets in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!