matlab.io.datastore.DsFileReader.hasdata - Determine if data is available to read - MATLAB (original) (raw)

Main Content

Class: matlab.io.datastore.DsFileReader
Namespace: matlab.io.datastore

Determine if data is available to read

Description

tf = hasdata([fr](#d126e447214)) returns logical1 (true) if there is data available to read from the file-reader object specified by fr. Otherwise,hasdata returns logical 0 (false).

Input Arguments

Examples

Determine if File-Reader Object Has Data to Read

Create a file-reader object for a file, check if the file has data to read, and then read the data.

Create a DsFileReader object forairlinesmall.csv.

fr = matlab.io.datastore.DsFileReader('airlinesmall.csv');

Check if the file has data to read using the hasdata method. Then, read the first 1000 characters.

if hasdata(fr) d = read(fr,1000,'SizeMethod','OutputSize','OutputType','char'); end

Version History

Introduced in R2017b