time | Calls | line |
---|
| | 29 | function [T,func] = executeImpl(func,supplied)
|
< 0.001 | 2 | 30 | rowNamesID = 0; rowNamesAsVariable = 0;
|
0.001 | 2 | 31 | if supplied.ReadRowNames && func.ReadRowNames && ~func.usingRowNames()
|
| | 32 | % User didn't define a rownamesColumn, but called readtable with ReadRowNames
|
| | 33 | func.Options.RowNamesRange = 1;
|
| | 34 | [rowNamesID,rowNamesAsVariable] = deselectRowNames(func);
|
< 0.001 | 2 | 35 | elseif supplied.ReadRowNames && ~func.ReadRowNames && func.usingRowNames()
|
| | 36 | % User specified a RowNamesColumn, but asked readtable not to import it.
|
| | 37 | % set the RowNames back to default
|
| | 38 | func.Options.RowNamesRange = '';
|
< 0.001 | 2 | 39 | end
|
| | 40 |
|
< 0.001 | 2 | 41 | checkWrongParamsWrongType(supplied);
|
| | 42 |
|
0.001 | 2 | 43 | if ~supplied.ReadVariableNames ...
|
| 2 | 44 | && func.Options.namesAreGenerated() ...
|
| 2 | 45 | && (isnumeric(func.Options.VariableNamesRange)...
|
| 2 | 46 | || func.Options.VariableNamesRange ~= "")
|
< 0.001 | 2 | 47 | func.ReadVariableNames = true;
|
< 0.001 | 2 | 48 | supplied.ReadVariableNames = true;
|
< 0.001 | 2 | 49 | end
|
| | 50 |
|
< 0.001 | 2 | 51 | try
|
< 0.001 | 2 | 52 | sheet = func.WorkSheet.SheetObj;
|
< 0.001 | 2 | 53 | assert(~isempty(sheet));
|
| | 54 | catch
|
| | 55 | [S, func] = executeImplCatch(func);
|
| | 56 | sheet = S.Sheet;
|
< 0.001 | 2 | 57 | end
|
< 0.001 | 2 | 58 | readingRowNames = rowNamesAsVariable||~isempty(func.Options.RowNamesRange);
|
< 0.001 | 2 | 59 | readingVarNames = supplied.ReadVariableNames && func.ReadVariableNames;
|
| | 60 |
|
< 0.001 | 2 | 61 | try
|
< 0.001 | 2 | 62 | UseExcel = func.WorkSheet.IsComObject;
|
| | 63 | catch
|
| | 64 | UseExcel = func.UseExcel;
|
< 0.001 | 2 | 65 | end
|
| | 66 |
|
< 0.001 | 2 | 67 | rssArgs = {'ReadVariableNames',readingVarNames,...
|
| 2 | 68 | 'ReadRowNames',readingRowNames,...
|
| 2 | 69 | 'Sheet',func.Options.Sheet,...
|
| 2 | 70 | 'UseExcel',UseExcel,...
|
| | 71 | 'FixVariableNames',false,...
|
| | 72 | };
|
| | 73 |
|
< 0.001 | 2 | 74 | if isfield(supplied,'TreatAsMissing') && supplied.TreatAsMissing
|
| | 75 | rssArgs = [rssArgs,{'TreatAsMissing',func.TreatAsMissing}];
|
< 0.001 | 2 | 76 | end
|
| | 77 |
|
0.068 | 2 | 78 | [data,metadata,func.Omitted] = matlab.io.spreadsheet.internal.readSpreadsheet(...
|
| 2 | 79 | sheet,func.Options,...
|
| 2 | 80 | rssArgs);
|
| | 81 |
|
0.003 | 2 | 82 | dimNames = matlab.internal.tabular.private.metaDim().labels;
|
| | 83 |
|
< 0.001 | 2 | 84 | if rowNamesAsVariable && rowNamesID > 0
|
| | 85 | % added the row names to the import variables, now take
|
| | 86 | % it out.
|
| | 87 | dimNames{1} = metadata.VariableNames{rowNamesID};
|
| | 88 | metadata.VariableNames(rowNamesID) = [];
|
| | 89 | data(rowNamesID) = [];
|
< 0.001 | 2 | 90 | elseif readingVarNames && readingRowNames
|
| | 91 | % Row Names Range was distinct from varnames, look at the
|
| | 92 | % intersecting cell
|
< 0.001 | 1 | 93 | dimNamesCell(1) = string(func.Options.RowNamesRange);
|
< 0.001 | 1 | 94 | dimNamesCell(2) = string(func.Options.VariableNamesRange);
|
| | 95 | % get the first cell, if there's more than one cell
|
< 0.001 | 1 | 96 | dimNamesCell(contains(dimNamesCell,':')) = extractBefore(dimNamesCell(contains(dimNamesCell,':')),':');
|
| | 97 | % take the column from RowNames, and the row from
|
| | 98 | % VariableNames and find the intersecting cell
|
< 0.001 | 1 | 99 | dimNamesCell(1) = regexprep(dimNamesCell(1),'\d','');
|
< 0.001 | 1 | 100 | dimNamesCell(2) = regexprep(dimNamesCell(2),'\D','');
|
< 0.001 | 1 | 101 | try % This range might be bad, or the data might not be a name
|
0.002 | 1 | 102 | range = [matlab.io.spreadsheet.internal.columnNumber(dimNamesCell{1}),...
|
| 1 | 103 | str2double(dimNamesCell{2}),1,1];
|
< 0.001 | 1 | 104 | d = sheet.readStrings(range);
|
< 0.001 | 1 | 105 | assert(~isempty(d{1}));
|
< 0.001 | 1 | 106 | dimNames{1} = d{1};
|
| | 107 | catch
|
| | 108 | % Ignore failures
|
< 0.001 | 1 | 109 | end
|
| 2 | 110 | end
|
| | 111 |
|
0.056 | 2 | 112 | T = matlab.io.internal.functions.ReadTable.buildTableFromData( ...
|
| 2 | 113 | data, ...
|
| 2 | 114 | metadata.VariableNames, ...
|
| 2 | 115 | metadata.RowNames, ...
|
| 2 | 116 | dimNames, ...
|
| 2 | 117 | readingVarNames, ...
|
| 2 | 118 | readingRowNames, ...
|
| 2 | 119 | func.Options.PreserveVariableNames);
|
0.004 | 2 | 120 | T.Properties.VariableUnits = metadata.VariableUnits;
|
0.008 | 2 | 121 | if isempty(T.Properties.VariableDescriptions)
|
| | 122 | T.Properties.VariableDescriptions = metadata.VariableDescriptions;
|
< 0.001 | 2 | 123 | end
|
< 0.001 | 2 | 124 | end
|
Other subfunctions in this file are not included in this listing.