%% Partition Datastore into Specific Number of Parts
% Create a datastore for a large collection of files. For this example, use ten copies of the sample file airlinesmall.csv. To handle missing fields in the tabular data, specify the name-value pairs TreatAsMissing and MissingValue.

files = repmat({'airlinesmall.csv'},1,10);
ds = tabularTextDatastore(files,...
                 'TreatAsMissing','NA','MissingValue',0);

% Partition the datastore into three parts and return the first partition. The partition function returns approximately the first third of the data from the datastore ds.

subds = partition(ds,3,1)

% The Files property of the datastore contains a list of files included in the datastore. Check the number of files in the Files property of the datastore ds and the partitioned datastore subds. The datastore ds contains ten files and the partition subds contains the first four files.

length(ds.Files)
length(subds.Files)

% Copyright 2012 The MathWorks, Inc.