Icon

kn_​example_​java_​if_​column_​exists_​switch

Use Java Snippet to check if Column is there, fill a FlowVariable and then activate if switch

Use Java Snippet to check if Column is there, fill a FlowVariable and then activate if switch



out_column = "column6";out_if_ = "top";for (int i = getColumnCount(); i-->0;) { if (out_column.equals(getColumnName(i))) { out_if_ = "bottom"; }} Use Java Snippet to check if Column is there, fill a FlowVariable and then activate if switchhttps://forum.knime.com/t/editing-java-snippet-node-to-check-if-column-exist-or-create-it/83963/4?u=mlauber71 You can decide what to do if the column is there (or not there).You can use all kinds of ports. Click on the three little dots at the Case Switch node if column isthere thenbottomcheck if "column6"is there and fill Flow Variablecreate column6(if it is not there)v_port0 = first port if the column does *not* existcheck if var_column_to_checkis there and fill Flow Variablev_portvar_column_to_check"column6"v_port0 = first port if the column does *not* existcreate column6(if it is not there)var_message"The Column does NOT exist"var_message"The Column DOES exist"columnExists(v_var_column_to_check) ? 1 : 0;colExists = 1 = port 1Column does existcolExists = 1 = port 1Column does existIF Switch Java Snippet Table Creator Math Formula End IF CASE Switch Start Java Snippet StringConfiguration CASE Switch End CASE Switch Start Math Formula CASE Switch End Java EditVariable (simple) Java EditVariable (simple) Java Snippet CASE Switch Start CASE Switch Start out_column = "column6";out_if_ = "top";for (int i = getColumnCount(); i-->0;) { if (out_column.equals(getColumnName(i))) { out_if_ = "bottom"; }} Use Java Snippet to check if Column is there, fill a FlowVariable and then activate if switchhttps://forum.knime.com/t/editing-java-snippet-node-to-check-if-column-exist-or-create-it/83963/4?u=mlauber71 You can decide what to do if the column is there (or not there).You can use all kinds of ports. Click on the three little dots at the Case Switch node if column isthere thenbottomcheck if "column6"is there and fill Flow Variablecreate column6(if it is not there)v_port0 = first port if the column does *not* existcheck if var_column_to_checkis there and fill Flow Variablev_portvar_column_to_check"column6"v_port0 = first port if the column does *not* existcreate column6(if it is not there)var_message"The Column does NOT exist"var_message"The Column DOES exist"columnExists(v_var_column_to_check) ? 1 : 0;colExists = 1 = port 1Column does existcolExists = 1 = port 1Column does existIF Switch Java Snippet Table Creator Math Formula End IF CASE Switch Start Java Snippet StringConfiguration CASE Switch End CASE Switch Start Math Formula CASE Switch End Java EditVariable (simple) Java EditVariable (simple) Java Snippet CASE Switch Start CASE Switch Start

Nodes

Extensions

Links