%% Read Timetable from File with Import Options
% Read a timetable from a text file by defining import options. Frist create the import options, update the datatypes of the variables, and then import the data.
% Create import options for outages.csv and display the detected variable options. The detectImportOptions function automatically detects and populates the import options object opts.

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

% Update the datatype of variables Region and Cause to categorical.

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

% Import the data into a timetable and display a summary.

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

% Copyright 2018 The MathWorks, Inc.