%% Create Timetable from File Using Import Options
% Detect import options for a text file, specify the variable types, and then create a timetable from the data.
% Create an import options object from a file and examine the variable options.

opts = detectImportOptions('outages.csv');
opts.VariableOptions

% Modify the options object to specify the desired datatypes for the variables in the data. Change the datatypes for the variables Region and Cause to categorical.

opts = setvartype(opts,{'Region','Cause'},{'categorical','categorical'});

% Use readtimetable along with the options object to import the timetable. Then display a summary of the timetable.

TT = readtimetable('outages.csv',opts);
summary(TT)

% Copyright 2018 The MathWorks, Inc.