time | Calls | line |
---|
< 0.001 | 45 | 1 | classdef TreatAsMissingInput < matlab.io.internal.FunctionInterface
|
| | 2 | %TREATASMISSING
|
| | 3 |
|
| | 4 | % Copyright 2018 MathWorks, Inc.
|
| | 5 | properties (Parameter)
|
| | 6 | %TREATASMISSING
|
| | 7 | % A cell array of character vectors which are to be treated as missing
|
| | 8 | % indicators for the variable when importing text data. When a missing
|
| | 9 | % indicator is found, the MissingRule is used to determine the
|
| | 10 | % appropriate action.
|
| | 11 | %
|
| | 12 | % Example, set the options to replace occurrences of 'NA' with '-':
|
| | 13 | %
|
| | 14 | % % when ImportOptions/MissingRule = 'fill'
|
| | 15 | % opts = matlab.io.TextVariableImportOptions();
|
| | 16 | % opts.TreatAsMissing = {'NA'};
|
| | 17 | % opts.FillValue = '-';
|
| | 18 | %
|
| | 19 | % When importing, any instances of 'NA' will be replaced with '-'
|
| | 20 | %
|
| | 21 | % See also matlab.io.VariableImportOptions
|
| | 22 | % matlab.io.spreadsheet.SpreadsheetImportOptions/MissingRule
|
| | 23 | % matlab.io.spreadsheet.SpreadsheetImportOptions/ImportErrorRule
|
| | 24 | % matlab.io.VariableImportOptions/FillValue
|
| | 25 | TreatAsMissing = {};
|
| | 26 | end
|
| | 27 |
|
| | 28 | methods
|
| | 29 | function obj = set.TreatAsMissing(obj,rhs)
|
| | 30 | if isnumeric(rhs) && isequal(rhs,[])
|
| | 31 | rhs = strings(0);
|
| | 32 | else
|
| | 33 | rhs = convertCharsToStrings(rhs);
|
| | 34 | end
|
| | 35 | if ~isstring(rhs) || any(ismissing(rhs),'all')
|
| | 36 | error(message('MATLAB:datastoreio:tabulartextdatastore:invalidTreatAsMissing'))
|
| | 37 | end
|
| | 38 | if isempty(rhs)
|
| | 39 | obj.TreatAsMissing = {};
|
| | 40 | else
|
| | 41 | obj.TreatAsMissing = cellstr(rhs);
|
| | 42 | end
|
| | 43 | end
|
| | 44 | end
|
| | 45 | end
|
| | 46 |
|
| | 47 |
|