Return logical indication of whether custom reader supports file
supported = supportsFile(obj,filename)
returns the logical value
supported = supportsFile(
supported that indicates whether the custom
reader specified by
obj supports the file specified by
filename. The Simulation Data Inspector always checks whether a file is
supported based on the file extension alone. Use the
supportsFile method to
specify code for additional support validation.
obj — Custom data reader
io.reader subclass object
Custom data reader, specified as an object of a class that inherits from the
filename — Name of file to import
character vector | string
Name of file to import, specified as a character vector or string.
supported — Whether custom reader supports file
Whether custom reader supports file, returned as a logical value.
Determine Whether Custom File Reader Supports File
Write the function definition for the
method to determine whether the custom reader supports the data in the file. This example
does not show a complete class definition. All custom readers must define behavior for the
methods. For an example that shows the complete class definition and import workflow, see
Import Data Using a Custom File Reader.
In this example, the
supportsFile method reads the data in the file
readtable function and checks that the file contains data
in more than one column.
classdef ExcelFirstColumnTimeReader < io.reader methods % ... function childObj = getChildren(obj) try t = readtable(filename); supported = height(t) > 0 && numel(t.Properties.VariableNames) > 1; catch supported = false; end end % ... end end
Introduced in R2020b