# Column filter ?

**URL:** <https://forum.knime.com/t/column-filter/116>\
**Category:** KNIME Analytics Platform\
**Created:** [May 24, 2007, 9:28pm UTC](https://forum.knime.com/t/column-filter/116 "2007-05-24T21:28:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![stanage](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/85f322/32.png) [@stanage](https://forum.knime.com/u/stanage)\
**Post date:** [May 24, 2007, 9:28pm UTC](https://forum.knime.com/t/column-filter/116/1 "2007-05-24T21:28:12Z")

</div>

Hi there,

Just a quick question about how to use KNIME. I need to compare the contents of two different columns, how can I do this in KNIME ?, splitting the output into two new tables, one where the str is found, the other not. For example:

Column1   
a  
b  
c

column2  
a  
d  
c

so comparing column1 with column2, the following would be returned;

Newtable1 (column1=column2)  
a  
c

Newtable2 (column1\<\>column2)  
d

The column1 and 2 comparison should be not limited to direct cell to cell comparison, but column1 cell1 to column2 ALL cells. But I can also envisage a direct cell to cell comparison function would be useful.

Do you have a node that can accomplish this comparison?, or workflow?

Really great product,

Stanage.

---

<div class="post-metadata">

**Author:** ![unknown\_user](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/ac91a4/32.png) [@unknown\_user](https://forum.knime.com/u/unknown_user)\
**Post date:** [May 24, 2007, 11:13pm UTC](https://forum.knime.com/t/column-filter/116/2 "2007-05-24T23:13:36Z")

</div>

**stanage wrote:**

> The column1 and 2 comparison should be not limited to direct cell to cell comparison, but column1 cell1 to column2 ALL cells. But I can also envisage a direct cell to cell comparison function would be useful.

  
Sorry, I didn't get it. How would a one-to-all-cell comparison look like for your example? A one-to-one-cell comparison is easy. Simply use the powerful Java Snipped node to append an additional column of type integer such as:  

```
$column1$.equals($column2$) ? 1 : 0
```
  
(if column1 and column2 are of type String, in the case of numeric columns just compare the two values by "==") Than use two Row Filter nodes to split up the table into two parts, one contains only the rows matching the '1' the other '0'. For table1 filter out either column1 or 2, and for the table2 column1, and in addition the newly added int column which was just used as an intermediate column for the Row Filter node. Done.

---

<div class="post-metadata">

**Author:** ![unknown\_user](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/ac91a4/32.png) [@unknown\_user](https://forum.knime.com/u/unknown_user)\
**Post date:** [May 25, 2007, 2:17pm UTC](https://forum.knime.com/t/column-filter/116/3 "2007-05-25T14:17:31Z")

</div>

Hi Gabriel,

What I am trying to do is find a value in a column table, ie.

Query str: Table1 column1 cell1 value = a

Find Query str value(a) in Table2 column1.

If found send query string (Table1 column1 cell1 value) to a found table, else send query string to not-found table. So this will effectively filter the input by creating a list of found /not found values in two seperate columns or tables.

I don't have the java skills to code this, and have looked at creating a new node for this function, but I definitily do not have the skills. Any help would be greatly appreciated.

Best regards,

Stanage.

---

<div class="post-metadata">

**Author:** ![unknown\_user](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/ac91a4/32.png) [@unknown\_user](https://forum.knime.com/u/unknown_user)\
**Post date:** [May 25, 2007, 2:39pm UTC](https://forum.knime.com/t/column-filter/116/4 "2007-05-25T14:39:06Z")

</div>

In order to run my example, you need to join (Joiner node) these two columns first into one table, which then is applied to the Java Snippet, two Row Filter nodes ( to separate the data into two tables again) and a Column Filter( to get read of the additional column). Works? We are still thinking about the one-cell-to-all problem...

---

<div class="post-metadata">

**Author:** ![unknown\_user](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/u/ac91a4/32.png) [@unknown\_user](https://forum.knime.com/u/unknown_user)\
**Post date:** [June 7, 2007, 10:32am UTC](https://forum.knime.com/t/column-filter/116/5 "2007-06-07T10:32:26Z")

</div>

Hi Gabriel,

I was wondering did you come up with any ideas on the one cell to all problem.

The reason for asking is that I have two columns of unequal length, and need to find the duplicate entries. Is it possible to get the two columns into a java array, and then perform a sort on this (see following thread for the general idea

[http://forum.java.sun.com/thread.jspa?threadID=503238&messageID=2382843](http://forum.java.sun.com/thread.jspa?threadID=503238&messageID=2382843)

).  
Anyhow if you can let me have your thoughts on this, that would be a great help.

Thanks in advance,

stanage.

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [June 23, 2023, 8:14pm UTC](https://forum.knime.com/t/column-filter/116/6 "2023-06-23T20:14:07Z")

</div>


