You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Matlab cannot concatenate tables with different number of columns/differently named columns, but there are times where this could be advantageous without paying overt risk - e.g. random appearance of phase, changing of internal structure between two sessions, etc. Basically, a column-wise version of intersect.
There are at least two critical points where this will cause the framework to have a hard fail: runBlock>appendRow and exportParticipant/exportTaskData.
The rough sketch of the helper:
uniqueToA = setdiff(A.Properties.VariableNames, B.Properties.VariableNames). Iterate over uniqueToA and add all of these with addConstantColumnToTable.
Same principle: uniqueToB = setdiff(B.Properties.VariableNames, A.Properties.VariableNames).
Concatenation should now work. If concatenation errors out, it's because two columns have different types. This is desirable in the addBlock case; less so in the export case.
The main pitfall is generating the right empty values for the type. The low-level version of this is a lookup table; the more elegant version is varTypeFn = str2func(class(A.(column)); B.(column) = varTypeFn.whateverFunctionMakesTheDefaultValue; (.empty is great, but won't work, since it's the MATLAB idiom for deletion); I should look into standardizemissing and fillmissing, if only for inspiration of missing values by type.
The text was updated successfully, but these errors were encountered:
Matlab cannot concatenate tables with different number of columns/differently named columns, but there are times where this could be advantageous without paying overt risk - e.g. random appearance of phase, changing of internal structure between two sessions, etc. Basically, a column-wise version of
intersect
.There are at least two critical points where this will cause the framework to have a hard fail:
runBlock>appendRow
andexportParticipant
/exportTaskData
.The rough sketch of the helper:
uniqueToA = setdiff(A.Properties.VariableNames, B.Properties.VariableNames)
. Iterate overuniqueToA
and add all of these withaddConstantColumnToTable
.uniqueToB = setdiff(B.Properties.VariableNames, A.Properties.VariableNames)
.addBlock
case; less so in the export case.The main pitfall is generating the right empty values for the type. The low-level version of this is a lookup table; the more elegant version is
varTypeFn = str2func(class(A.(column)); B.(column) = varTypeFn.whateverFunctionMakesTheDefaultValue;
(.empty
is great, but won't work, since it's the MATLAB idiom for deletion); I should look intostandardizemissing
andfillmissing
, if only for inspiration of missing values by type.The text was updated successfully, but these errors were encountered: