Datastore - support for mat-files
Show older comments
I am trying to use the tall array functionality to sort a very large table, as well as other calculations. The tables are currently stored in several mat-files. When trying to create a datastore object to be used as input to the tall arrays, using one or more mat-file as inputs does not seem to be possible.
Am I missing something? Do I have to export the data to some other format to use as input for the datastore object? Any input would be appreciated.
Accepted Answer
More Answers (3)
Steven Lord
on 14 Jun 2017
2 votes
Have you seen this example in the documentation? Alternately, the documentation page for FileDatastore includes an example that creates a datastore for a collection of MAT-files. That might allow you to turn your collection of table arrays into a tall table.
MSTK
on 10 Aug 2017
0 votes
bigdataanalyses
on 9 Nov 2021
0 votes
Hoping this helps someone:
Task at hand: After producing one very large 2D-table in Matlab via smaller table excerpts, I save each excerpt as a separate .mat-file. However, the re-loading causes problems.
Problem: Re-loading the tables stored as .mat via fileDatastore( ) and then transforming them to tall( ) makes each row in the table its own subtable.
Solution: After some trial-and-error, this works:
ds = fileDatastore(fullfile('input','database_regdata_*.mat'),... % the * is for the numbering of the outputted files
'ReadFcn', @(x)struct2table(load(x)), ... % Try to convert structure to table to avoid error in tall( )
"FileExtensions",".mat",...
"UniformRead", true); % one big table with same variables, o/w error
% Turn datastore into tall array for analysis out of memory.
tt = tall(ds);
ttt = vertcat(tt{:,:});
Categories
Find more on Text Data Preparation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!