Remove column if is empty

Hello,
I have a table, in all columns are strings. I need to do a test for several columns in this table, which determine empty columns. I need to identify empty columns because of the next steps in my workflow.
I think that a good solution of my problem can be the node “java snippet” and the nodes “if switch” “end if”. But I have defined if condition unsuccessfully in the “java snippet” node because I do not know the java language. Please help me with the definition of the If condition.
I need e.g.
if the column is empty, activate the top port of the “if switch” node
If the column is not empty, activate the bottom port of the “if switch” node

Thank you so much for your advice and help
Thillia

Hi @Thillia_01 , you can use the Missing Value Column Filter node. Just make sure that your Missing value threshold is at 100%

Let’s say your table is like this:
image

As you can see, column4 and column6 are empty columns.

After using the node, they are removed:
image

Very simple demo that looks like this:
image

2 things to configure:

  1. Make sure you are using “Enforce exclusion” option and leave it empty. That way it will not exclude any columns, and therefore include all columns.
  2. Make sure your Missing value threshold is at 100%. That means all the rows of the column are missing.

Here’s the workflow: Remove column if is empty.knwf (7.1 KB)

8 Likes

I really love @bruno29a 's solution. I guess Low Variance Filter node points into the same direction.
br

1 Like

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