Picking different column name if it already exists

I know, that there is some pre-existing method which would automatically suggest a different column name, in case the respective output table would already contain such a column. 

E.g. node wants to append column with name 'myColumn', but table already has that column, the method would return something like 'myColumn (#1)' or similar.

I thought it was in DataColumnSpec or -Creator, but I cannot find it. Can someone please enlighten me? :)

Answering my own question:

org.knime.core.data.DataTableSpec.getUniqueColumnName(DataTableSpec, String)

 

Hi,

just a addon, if you need more than one you can also use the class UniqueNameGenerator.

https://tech.knime.org/docs/api/org/knime/core/util/UniqueNameGenerator.html

 

Best, Iris

Cool, good to know! Thanks! :)

Greetings,
Philipp

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.