Appending a column to a DataTable.

Hey,

I have just rewritten this as i think it was confusing.

I have been trying to append an array of values to a BufferedDataTable for a while now.

I basically have a double array of values which needs to be added to a BufferedDataTable as the final column.

I have been using ColumnRearranger objects and the .append() method. Passing an AbstractCellFactory as the parameter.

I think this is wrong because every element in the output datatable is the same as the first element in my array, regardless of the fact that not all elements in the array are equal to the first element.

I appreciate any advice with regards to this :slight_smile:

1 Like

Hi @toblatp
I think the easiest approach is to create a ListCell that contains your array data.
One of the easier ways to do this is to make use of the converter framework, e.g. as shown in the following example code from a unit test. This probably requires the least boilerplate code.

Best,
Gabriel

Hey Gabriel,

Thanks for the resources, I am just feeling a bit lost as to how those tie in to BufferedDataTables? I can see how you instantiate a ListCell object now, but how would i go about adding it to the BufferedDataTable.

Sorry, I am just so confused with so many different classes.

Appreciate your help :slight_smile:

Hey @toblatp,
No worries, getting started with node development is not that easy. To add a ListCell to a Table, best look at the source code of the Create Collection Column node.

  1. In the execute method a ColumnRearanger is used, which is a efficient way to create an output that is based on modifying some input columns.
  2. The ColumnRearanger itself is created in the method bellow, important for you is the not the column selection logic in the first half, but the code here. Which should not be too hard to adapt to your needs.

best,
Gabriel

PS: If all you want to do is to turn a Column into a List, you can use List aggregation method in the GroupBy node.