time | Calls | line |
---|
< 0.001 | 45 | 1 | classdef CommonVarOpts < matlab.io.internal.FunctionInterface
|
| | 2 | %
|
| | 3 |
|
| | 4 | % Copyright 2018 The MathWorks, Inc.
|
| | 5 |
|
| | 6 | properties (Parameter)
|
| | 7 | %QUOTERULE
|
| | 8 | % How surrounding quotes in text should be treated.
|
| | 9 | %
|
| | 10 | % 'remove' - If converting from text, and the field begins with a double
|
| | 11 | % quotation mark ("), omit the leading quotation mark and its
|
| | 12 | % accompanying closing mark, which is the second instance of a
|
| | 13 | % lone double quotation mark. Replace escaped double quotation
|
| | 14 | % marks (for example, ""abc"") with lone double quotation
|
| | 15 | % marks ("abc"). Ignore any double quotation marks that appear
|
| | 16 | % after the closing double quotation mark.
|
| | 17 | %
|
| | 18 | % 'keep' - retain all quote marks. NOTE: This may cause conversion to
|
| | 19 | % fail for some types.
|
| | 20 | %
|
| | 21 | % 'error' - Report an error when converting data which begins with a
|
| | 22 | % double-quote character ("). Use this setting if the field
|
| | 23 | % should never be quoted.
|
| | 24 | %
|
| | 25 | % See also matlab.io.VariableImportOptions
|
| | 26 | QuoteRule = 'remove';
|
| | 27 |
|
| | 28 | %PREFIXES
|
| | 29 | % A cell array of character vectors or a string vector containing
|
| | 30 | % the prefix characters that need to be removed from the
|
| | 31 | % variable on import.
|
| | 32 | %
|
| | 33 | % See also matlab.io.VariableImportOptions
|
| | 34 | Prefixes = {};
|
| | 35 |
|
| | 36 | %SUFFIXES
|
| | 37 | % A cell array of character vectors or a string vector containing
|
| | 38 | % the suffix characters that need to be removed from the
|
| | 39 | % variable on import.
|
| | 40 | %
|
| | 41 | % See also matlab.io.VariableImportOptions
|
| | 42 | Suffixes = {};
|
| | 43 |
|
| | 44 | %EMPTYFIELDRULE Procedure to manage empty variable fields
|
| | 45 | %
|
| | 46 | % 'missing' - treat empty fields as missing data and follow the
|
| | 47 | % procedure specified in the MissingRule property.
|
| | 48 | %
|
| | 49 | % 'error' - treat empty fields as import errors and follow the
|
| | 50 | % procedure specified in the ImportErorrRule
|
| | 51 | % property.
|
| | 52 | %
|
| | 53 | % 'auto' - convert empty fields to type-specific values.
|
| | 54 | % For example, when variable is of type:
|
| | 55 | %
|
| | 56 | % text - import as zero length char
|
| | 57 | % or string
|
| | 58 | % numeric:
|
| | 59 | % 1) floating-point - import as NaN
|
| | 60 | % 2) integer - import as 0
|
| | 61 | % duration - import as NaN
|
| | 62 | % categorical - import as <undefined>
|
| | 63 | % datetime - import as NaT
|
| | 64 | % logical - import as false
|
| | 65 | %
|
| | 66 | % See also matlab.io.VariableImportOptions
|
| | 67 | % matlab.io.spreadsheet.SpreadsheetImportOptions/ImportErrorRule
|
| | 68 | % matlab.io.VariableImportOptions/FillValue
|
| | 69 | % matlab.io.spreadsheet.SpreadsheetImportOptions/MissingRule
|
| | 70 | EmptyFieldRule = 'missing';
|
| | 71 | end
|
| | 72 |
|
| | 73 | methods
|
| | 74 | function obj = set.QuoteRule(obj,rhs)
|
| | 75 | obj.QuoteRule = validatestring(rhs,{'remove','keep','error'});
|
| | 76 | end
|
| | 77 |
|
| | 78 | function obj = set.Prefixes(obj, val)
|
| | 79 | obj.Prefixes = validateAndSortByLength(val,'MATLAB:textio:textio:InvalidPrefixes');
|
| | 80 | end
|
| | 81 |
|
| | 82 | function obj = set.Suffixes(obj, val)
|
| | 83 | obj.Suffixes = validateAndSortByLength(val,'MATLAB:textio:textio:InvalidSuffixes');
|
| | 84 | end
|
| | 85 |
|
| | 86 | function obj = set.EmptyFieldRule(obj,rhs)
|
| | 87 | obj.EmptyFieldRule = validatestring(rhs,{'missing','error','auto'});
|
| | 88 | end
|
| | 89 | end
|
| | 90 | end
|
| | 91 |
|
| | 92 | function val = validateAndSortByLength(val,msgID)
|
| | 93 | val = convertCharsToStrings(val);
|
| | 94 | if ~isstring(val)
|
| | 95 | error(message(msgID));
|
| | 96 | end
|
| | 97 | [~,idx] = sort(strlength(val),'descend');
|
| | 98 | val = cellstr(val(idx));
|
| | 99 | end
|