Skip reading a file with file datastore
Show older comments
I'm using a file datastore to read log files. I'm using a while loop to read files in datastore. In some cases the file reader is not able to read a file and will throw an error. If this happens, the file datastore does not move forward to the next file and is stucked trying to read the same file.
I would like to be able to continue reading the next file in the datastore if this happens.
Are there a nextfile(fds) function or similar that can change the progress of the datastore?
Alternatively I have to make a recursive call for a new file datastore based on the remaing subset of data and merge the output together. I would like to avoid that.
% Read through the file datastore and store data
ii=1;
reset(fds)
hwait = waitbar(0, '0', 'Name', 'Reading data');
while hasdata(fds)
try
Data{ii, :} = read(fds);
catch
% flag file and move to next
flaggedfiles{end+1}
end
ii = ii + 1;
waitbar(progress(fds), hwait, sprintf('%2.0f %%', progress(fds) * 100));
end
Accepted Answer
More Answers (0)
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!