Adding a new empty column to a table

Hi,

I'm beginning to use Knime and I have finished to read me all available information about it, but I have a basic problem. I'm trying to add a empty column to a table unsuccessfully.

The task I want to do it is to introduce new columns in a table with the information collected by another program, which is executed through the node. But, as first step, I need to be able to add a new empty column. And for that, I had modified the following funtions of NodeModel.

 

@Override
    protected BufferedDataTable[] execute(final BufferedDataTable[] inData,
            final ExecutionContext exec) throws Exception {
        ColumnRearranger rearranger = new ColumnRearranger(inData[0].getDataTableSpec());
        BufferedDataTable result = exec.createColumnRearrangeTable(inData[0], rearranger, exec);
        return new BufferedDataTable[]{result};
    }
    
    private ColumnRearranger createColumnRearranger(final DataTableSpec spec)
    throws InvalidSettingsException {
        ColumnRearranger result = new ColumnRearranger(spec);
        DataColumnSpecCreator appendSpecCreator = new DataColumnSpecCreator("NewColumn", StringCell.TYPE);
        DataColumnSpec appendSpec = appendSpecCreator.createSpec();      
        result.append(new SingleCellFactory(appendSpec){
            public DataCell getCell (final DataRow row){
                DataCell resultCell = row.getCell(0);
                if (resultCell.isMissing()) {
                    return DataType.getMissingCell();
                }
                return resultCell;
            }
        });
        return result;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected DataTableSpec[] configure(final DataTableSpec[] inSpecs)
            throws InvalidSettingsException {
        ColumnRearranger rearranger = createColumnRearranger(inSpecs[0]);
        return new DataTableSpec[]{rearranger.createSpec()};
    }

 

If anyone has had problems to receive information collected by other program executed through the node, I would like to know it since it's my next step.

Thank you so much

Use the transpose node, add an empty node and transpose back.

Sometimes, the setting for adding particular values in the add empty rows do not work. In that case add them with missing values and use the missing value node later.