How to Merge 500 tables with occsaional different dates in their date column
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear Expert Users, I'd like to merge my 500 tables, each table is a stock's daily ~6 to 12-yr history. Each table has 7-columns with the first column as yyyyMMdd, 4 columns in $ for hi/low/close/open prices, 1 column for amt of volume traded on that day, and last column is just one I added that is the "ticker" stringvar for that stock (duplicated on every line for eveery day of historical date).
I looked at using merge but each table is a different length. I tried to use join but some dates are missing. I tried to use Financial Tool, however, I have a single file with 500-tables so it is not reading varibles in app.
Do I have any options?
Thank you. --AR
0 Kommentare
Akzeptierte Antwort
Peter Perkins
am 9 Nov. 2016
Is outerjoin what you are looking for?
>> t1 = table(datetime(2016,1,[1;2;3;5]),[1;2;3;4],[5;6;7;8]);
>> t2 = table(datetime(2016,1,[2;4;5;6]),[9;10;11;12],[13;14;15;16]);
>> outerjoin(t1,t2,'Keys','Var1','MergeKeys',true)
ans =
Var1 Var2_t1 Var3_t1 Var2_t2 Var3_t2
___________ _______ _______ _______ _______
01-Jan-2016 1 5 NaN NaN
02-Jan-2016 2 6 9 13
03-Jan-2016 3 7 NaN NaN
04-Jan-2016 NaN NaN 10 14
05-Jan-2016 4 8 11 15
06-Jan-2016 NaN NaN 12 16
If you have access to R2016b, you should look at using timetables.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Preprocessing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!