matlab.io.datastore.DsFileReader Class
Namespace: matlab.io.datastore
File-reader object for files in a datastore
Description
The DsFileReader
object enables low-level file reading access for
files in your datastore.
Construction
fr = matlab.io.datastore.DsFileReader(
returns a filename
)DsFileReader
object for read access to the file specified
by filename
.
fr = matlab.io.datastore.DsFileReader(
specifies the character encoding scheme associated with the file. Additionally,
specifying filename
,'TextEncoding',encoding
)encoding
sets the TextEncoding
property
of the DsFileReader
object.
Input Arguments
Properties
Methods
Examples
Read File Portion Specified by Starting Position and Size
Create a file-reader object for a file, seek to the desired starting position, and read a portion of the file.
Create a DsFileReader
object for
airlinesmall.csv
.
fr = matlab.io.datastore.DsFileReader('airlinesmall.csv');
The airlinesmall.csv
file has variable names at the beginning
of the file. The variable names line ends at the position marked by
299
bytes. To get past the variable names line, use the
seek
method to move the read pointer to the starting
position.
seek(fr,299,'RespectTextEncoding',true);
Read the first 1000
characters.
if hasdata(fr) d = read(fr,1000,'SizeMethod','OutputSize','OutputType','char'); end
Version History
Introduced in R2017b