Create sequential IDs for rows

7.3k views Asked by At

In Knime, how do I Create sequential IDs for rows. I want to use them for assigning primary IDs in a dimension.

Also I want to know, how do I only take a limited number of rows, (like top 5 or bottom 10), and get a random sample

2

There are 2 answers

0
Karn On BEST ANSWER

Try adding the Data Generation to your KNIME version.

If it is already installed, search for the node "Counter Generation". It will easily generate sequential IDs. It has 2 parameter. Start From and Interval.

You may want to start from 1 and have step intervals of 1 to generate IDs like 1,2,3,4,5.

As for the Random rows, you can use the node "Row Sampling". It has many parameters, but for what concerns you, you may set it as the following:

Absolute-5 (To get 5 rows) Take from top (To get top 5)

To draw 5 rows randomly from the set, simply select "Draw Randomly".

0
SteveR On

The RowID node will generate new sequential row IDs. If you want a column with an integer sequential index, try a Java Snippet - add an integer column output and set it's value in the snippet code to be the ROWINDEX from the column selector in the top left.