Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helper for concatenating disparate table rows #89

Open
shippy opened this issue Mar 17, 2017 · 1 comment
Open

Helper for concatenating disparate table rows #89

shippy opened this issue Mar 17, 2017 · 1 comment

Comments

@shippy
Copy link
Contributor

shippy commented Mar 17, 2017

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:

  1. uniqueToA = setdiff(A.Properties.VariableNames, B.Properties.VariableNames). Iterate over uniqueToA and add all of these with addConstantColumnToTable.
  2. Same principle: uniqueToB = setdiff(B.Properties.VariableNames, A.Properties.VariableNames).
  3. 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.

@shippy shippy added this to the Next run milestone Mar 17, 2017
@shippy shippy added the feature label Mar 17, 2017
@shippy
Copy link
Contributor Author

shippy commented Jul 9, 2017

Here's a MathWorks forum answer, which has been noted #12.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant