%% Specify Format of Data to Read
% Create a datastore from the sample file airlinesmall.csv, which contains tabular data.

ds = tabularTextDatastore("airlinesmall.csv","TreatAsMissing","NA",...
    "MissingValue",0);

%
% Specify the variables of interest.

ds.SelectedVariableNames = ["Year","Month","UniqueCarrier"];

%
% View the SelectedFormats property.

ds.SelectedFormats

% The SelectedFormats property specifies how the tabularTextDatastore function interprets the format of the variables. The Year and Month variables are read as columns of floating-point values and the  UniqueCarrier variable as a column of text.
%
% Modify the SelectedFormats property to read the first two variables as signed integers and the third variable as a categorical value.

ds.SelectedFormats = ["%d","%d","%C"];

%
% Preview the data.

T = preview(ds)

% Copyright 2012 The MathWorks, Inc.