hi , how can i write more than one rule for the same column in column expression node ?
Welcome to the forum @orobbsh
I don’t think you’ve provided enough information to get the kind of answer you want or a useful answer.
The simple answer is: just add as many different expressions as you want. What’s stopping you from doing this?
What “rules” are you trying to write?
Why are you specifically wanting to use the column expressions node instead of (for example) a Rule Engine node?
What exactly is it that you’re trying to accomplish?
i have column with different values like cash ,visa , credit , they are written in a wrong noisy way such as ( cas h , cashh , vsa) , so i want to replace (cas h,cashh) and put cash instead of them .
i try to use rule engine but when i write the function , it apply it and put the rest of values as missing value .
What expression(s) have you tried in the Column Expressions node?
What’s stopping you from adding as many different expressions as you want?
What rule(s) did you try in the Rule Engine node?
Have you tried any of the string replace nodes?
Hi @orobbsh and welcome to the Knime Community. It looks like you are trying the Column Expression and also trying the Rule Engine. Both are good approach to what you are trying to do, and in turn, each has more than 1 way of doing this.
Let’s first look at what you did/said:
This is most certainly happening because you did not choose a default value, which is the "
TRUE => " statement.
However, before suggesting anything, we have to know in that column of yours, do you only have only a variation of cash/visa? Or are these part of a string? In other words, does a row in that column contains just
cas h, or
cassh, etc, or is it part of a string like “
the client paid with cas h”?
thank you bruno29a , i don’t write "
TRUE => " statement. because i want to replace the wrong data and Remains the correct value such as cash as it ( i mean it is correct so i don’t want to change it . ( this is for rule engine)
for column expression i use ( replace function ) for more than one value in the same column , but it apply it at the last function and change one value.
1- i tried replace in Column Expressions node
2-i tried this , example ($c_credit_card$ =“vissa”=>“visa”)
and i don’t write TRUE => “default outcome” because i want to remain the right values as it is
3- i tried string manipulation node but i can not know how it is be useful for more than one function .
Well, that’s exactly what the
TRUE => statement is for.
That’s like saying “I don’t drink” and then complaining that you are thirsty.
If you would want to write what you want in and if statement, it would look like:
if (condition) then assign some value else remain the same
Translating to the Rule Engine:
condition => some value TRUE => remain the same
If you don’t write the
TRUE => statement, that’s like not writing the else statement. So Knime does not know what value to use, hence why when it’s true, it changed as you expected, and when the condition was false, nothing got written.
Also, you have not answered the question I asked: " we have to know in that column of yours, do you only have only a variation of cash/visa? Or are these part of a string? In other words, does a row in that column contains just
cas h , or
cassh , etc, or is it part of a string like “
the client paid with cas h ”?". If it is the latter, then you have to use replace and can’t do this this via the Rule Engine. If it’s alone, then it can be done in the Rule Engine.
i try your solution about using TRUE => remain the same , and the problem solved , thank you , and the column is not a part of a string .
i try to use the solution on onther case ( column that have name of companies (500) and there is more than one name for the same company , should i use table creator and put the right values then use replacer . or can i use rule engine ??
No problem @orobbsh. So you can use Rule Engine for the cash/credit/visa, etc if they’re not part of a string, and you add different rules in the same Rule Engine. For example:
$your_column$ IN ("cassh", "cas h") => "cash" $your_column$ IN ("vsa", "vis") => "visa" $your_column$ IN ("cre", "cr", "cred") => "credit" TRUE => $your_column$
For the company names, it could be more complicated assuming that they may be multiple words.
Can you give some examples?
yes this is an example :
Expedia Cash $
Expedia Cash Ns
these are name of company or website that customer come from it , so these names we can replace them and put Expedia .
i have 500 row and i want to put the same name of the company instead of have more than one name.
The trick here is to recognize pattern. For example, if we take the sample that you gave, they all seem to correctly start with Expedia, so a rule could be:
$your_column$ LIKE "Expedia *" => "Expedia"
Obviously it would not work if the data is “Expdia something”, in which case you have to add another rule for that.
You also need to be careful some some names are subsets of another name. For example “Disney” and “Walt Disney”, so if you apply a rule for Disney, it can also affect Walt Disney. In this case you may need to do 2 operations, and order will be important.
so can i use table creator node then cell replacer node ?
As a replacement map? Yes
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.