Main Content

io.reader.getSupportedReadersForFile

Class: io.reader
Namespace: io

Return all readers available to import file

Since R2020b

Syntax

readers = io.reader.getSupportedReadersForFile(filename)

Description

readers = io.reader.getSupportedReadersForFile(filename) returns all readers in the Simulation Data Inspector that support importing the file specified by filename.

Input Arguments

expand all

Name of or path to file to import, specified as a character array or string.

Example: 'MyDataFile.csv'

Data Types: char | string

Output Arguments

expand all

File readers available to import file, returned as an array of strings. When the Simulation Data Inspector has a built-in reader for the file, the array contains "built-in".

Attributes

Statictrue

To learn about attributes of methods, see Method Attributes.

Examples

expand all

This example shows how to register a custom file reader with the Simulation Data Inspector, verify registration was successful, and unregister a file reader.

Register the Custom File Reader

This example registers the file reader ExcelFirstColumnTime. For an example that shows how to author the custom file reader, see Import Data Using Custom File Reader. As the name suggests, the custom file reader for this example supports Microsoft Excel™ files. Register the reader for the .xlsx and .xls extensions.

registerFileReader(ExcelFirstColumnTimeReader, [".xlsx" ".xls"]);

Verify Custom Reader Registration

To verify registration of a custom reader, you can use the io.reader.getRegisteredFileReaders method or the io.reader.getSupportedReadersForFile method.

The io.reader.getRegisteredFileReaders returns a string array that contains the names of all registered custom file readers.

io.reader.getRegisteredFileReaders
ans = 
"ExcelFirstColumnTimeReader"

You can also use the io.reader.getSupportedReadersForFile method to see all reader options for a specific file. The built-in option in the returned string array indicates that the Simulation Data Inspector has a built-in Excel file reader.

 io.reader.getSupportedReadersForFile('CustomFile.xlsx')
ans = 1x2 string
    "ExcelFirstColumnTimeReader"    "built-in"

Unregister a Custom File Reader

To unregister a custom file reader, use the unregisterFileReader method. All custom readers are unregistered when you close a MATLAB™ session.

unregisterFileReader(ExcelFirstColumnTimeReader, [".xlsx" ".xls"])

Version History

Introduced in R2020b