Read all data in datastore
Create a datastore from the sample file airlinesmall.csv
, which contains tabular data.
ds = tabularTextDatastore('airlinesmall.csv','TreatAsMissing','NA',... 'MissingValue',0);
Modify the SelectedVariableNames
property to specify the variables of interest.
ds.SelectedVariableNames = {'DepTime','ArrTime','ActualElapsedTime'};
Read all the data in the datastore.
T = readall(ds);
readall
returns all the data in a table.
View information about the table.
T.Properties
ans = TableProperties with properties: Description: '' UserData: [] DimensionNames: {'Row' 'Variables'} VariableNames: {'DepTime' 'ArrTime' 'ActualElapsedTime'} VariableDescriptions: {} VariableUnits: {} VariableContinuity: [] RowNames: {} CustomProperties: No custom properties are set. Use addprop and rmprop to modify CustomProperties.
View a summary of the output table.
summary(T)
Variables: DepTime: 123523x1 double Values: Min 0 Median 1327 Max 2505 ArrTime: 123523x1 double Values: Min 0 Median 1511 Max 2608 ActualElapsedTime: 123523x1 double Values: Min 0 Median 100 Max 1650
Create a datastore from the sample file, mapredout.mat
, which is the output file of the mapreduce
function.
ds = datastore('mapredout.mat');
Read all the data in the datastore.
T = readall(ds);
View a summary of the output table.
summary(T)
Variables: Key: 29x1 cell array of character vectors Value: 29x1 cell
Create a datastore that maintains parity between the pair of images of the underlying datastores. For instance, create two separate image datastores, and then create a combined datastore representing the two underlying datastores.
Create an image datastore imds1
representing a collection of three images.
imds1 = imageDatastore({'street1.jpg','street2.jpg','peppers.png'});
Create a second datastore imds2
by transforming the images of imds1
to grayscale and then downsizing the images.
imds2 = transform(imds1,@(x) imresize(rgb2gray(x),0.5));
Create a combined datastore from imds1
and imds2
.
imdsCombined = combine(imds1,imds2);
Read all of the data from the combined datastore. The output is a 3-by-2 cell array. The two columns represent all of the read data from the two underlying datastores imds1
and imds2
, respectively.
dataOut = readall(imdsCombined)
dataOut=3×2 cell array
{480x640x3 uint8} {240x320 uint8}
{480x640x3 uint8} {240x320 uint8}
{384x512x3 uint8} {192x256 uint8}
ds
— Input datastoreInput datastore. You can use these datastores as input to the
readall
method.
MATLAB® datastores — Datastores created using MATLAB
datastore
functions. For example, create a datastore for a collection of
images using ImageDatastore
.
For a complete list of datastores, see Select Datastore for File Format or Application.
Combined and transformed datastores — Datastores created using
the combine
and transform
functions.
Custom datastores — Datastores created using the custom datastore framework. See Develop Custom Datastore.
data
— All data in the datastoreAll data in the datastore, returned as a table or a cell array depending
on the type of ds
.
Type of Datastore | Data type of data | Description |
---|---|---|
TabularTextDatastore and
SpreadsheetDatastore | Table | The SelectedVariableNames property
determines the table variables. |
ImageDatastore | Cell array | Each element in the cell array contains the image data
for one image. The readall function
supports all image types supported by the
imread function. For more information
on the supported image types, see imread . |
KeyValueDatastore | Table | The table variable names are Key and
Value . |
FileDatastore | Cell array | Each element in the cell array contains the data read
from one file using the custom read function specified by
the ReadFcn property. |
TransformedDatastore | Varies | The output is the same as the output returned by the
underlying datastore specified by the
UnderlyingDatastores property. For
example, if the underlying datastore is an image datastore,
then data is returned as a cell array
where each element in the cell array contains the image data
for one image. |
CombinedDatastore | Cell array | Each column of the cell array contains the result
from calling If the number of subsets of data
in the underlying datastores differs, then
|
You have a modified version of this example. Do you want to open this example with your edits?