rule-based row filter check if a value only contains numbers.

i dont know how i can do this.

I tried to use java snipet simple.

my code:

    int isDigit;
string text;

text = $POSITIONSTEXT$;
if (text.matches("[0-9]+") && text.length() > 2) {
	isDigit = 1;
}else {
      	isDigit = 0;
}

return isDigit;

but my code doesnt’ work. anybody have maybe a solution for java snipe simple and also for a simple rule based row filter?

Hi,

Use capital S for String:
String text;

:blush:

P.S. Just as a hint: You have to set the return type to Integer.

Hi there @Paddymaster ,

did you solve it?

You can use Rule-based Row Filter node but only is filtering is what you need obviously. Also length is something you should calculate prior to Rule-based Row Filter node. Additionally Column Expressions node is way to do it as well.

Br,
Ivan

1 Like

that was the mistake.
With the uppercase String i could do that.

@ipazin How can i do that with the rule-based row filter ? Can’t select only numbers

1 Like

Hi there,

you would like to check if a String contains only numbers and if so leave that row otherwise filter that row? If I haven’t understood you properly can you share a input data and desired output?

Br,
Ivan

1 Like

i upload a sample file.

In the solution i’ll check a column. If a value of the column is NULL or contains only numbers i will include these rows to the final table.

Testdigit.knwf (14.6 KB)

Hi,

tnx for workflow but you have reset checkbox clicked while exporting so no data can be seen…

Br,
Ivan

1 Like

testdigit.xlsx (8.1 KB)

now the xls is also online :slight_smile:

3 Likes

Hi there!

This should do the trick in one node (Rule-based Row Filter). I guess :smiley:

$Spalte4$ MATCHES "^[0-9]+$" OR MISSING $Spalte4$ => TRUE

Br,
Ivan

2 Likes

i add $Spalte4$ = “” to the rule-based row filter.

thats the solution:

thx

2 Likes

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