checking the existence of timetable and merge

4 views (last 30 days)
Sehoon Chang
Sehoon Chang on 3 Sep 2020
Edited: Jon on 3 Sep 2020
within a folder i have diverse excel data type, which are imported and then converted to timetable within MATLAB.
(eg. timetable_csv, timetable_xls,timetable_xlsb, etc.)
It is possible that all of the timetables of various data type exist or only a few types exist depending on the content of the folder.
However, the name of all timetable do exist.
At the end i wish to merge all the existing timetable into one using the code 'outerjoin'.
How may i find out which of the timetables do exist and can be merged with other existing timetables?
I tried to merge each timetables like it is show below. However, the processing stops due to the timetable that do not exist (empty).
timetable = outerjoin(timetable_xltx,outerjoin(timetable_xltm,outerjoin(timetable_xlsx,outerjoin(timetable_xlsm,outerjoin(timetable_xlsb,outerjoin(timetable_csv,timetable_xls))))))

Answers (1)

Jon on 3 Sep 2020
Edited: Jon on 3 Sep 2020
If it is a question of whether the variables have been created at all, you can check whether they exist using the exist MATLAB command, e.g. and branch accordingly
if exist('timetable_xltm') ...
If the variables always exist, but sometimes there is nothing in them, that is they are empty, you can test for that using the MATLAB command isempty, e.g. and branch accordingly
if isempty(timetable_xltm) ...

Community Treasure Hunt

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

Start Hunting!