Help with Java Snippet, lost on how to loop through rows and apply a switch case flow

Bare with me, as I’ve been introducing myself to java recently.

Basically, what I want to with the Java Snippet is something similar to this pseudo code.

for index of gender_column:
	switch gender_column[index]:
	
		case "m":
			new_column[index] = values_column[index]
			break

		case "f":
			new_column[index] = values_column[index] * -1
			break

		case "u":
			new_column[index] = 0
			break

I know I can install python and Conda, but I want to do it with Java as I’m trying to learn as well.

The problem is that the node documentation only gives, as a hint, getCell(name, type) and I’m having a hard time trying to wrap my head about these things:

  1. How exactly does getCell() get the value of a cell with only the column name and the data type as parameters? I thought of using some kind of index.getCell() but I don’t see how exactly.

  2. What kind of collections are the columns of the left? As I don’t have a Java Console output I can’t try to see if it’s arrays of something else, I’m pretty lost. Same with ROWINDEX etc. Nothing shows up in the Knime Console either.

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