Cell Splitter

Hello, colleagues,

Today I touched the problem with Cell Splitting. I have the column “Location”. I need to split all part into separate columns. The most important thing that I need to have at least one column with Country. Due to the fact that in case of USA, here in the cell I have the name of the state I have such problem (see the pic 2). How to combine / join USA with the rest countries into one column? And the State leave as it is in the separate one?


Hi @Felis90,

I‘d personally prefer using RegEx but without sample date to work with I cannot create on for you. In your case you might just use a Rule Engine to copy the String from the fore last into the last column if the cell
Is missing. Then another rule engine to flush the original value.

Best
Mike

It would be a lot easier to help if you’d share some sample data.

1 Like

Hi @Felis90,

If the problem is simply with the USA country column, we can use simple logic with Column Expression node

If the value in Location_Arr[3] is “USA”, return the value from Location_Arr[3] Otherwise, return the value from Location_Arr[2] .

Remove the country values from Location_Arr[2] column.

Cell Splitter.knwf (74.3 KB)

If there is issues with other country columns as well, please upload sample data

Regards,
Yogesh

@yogesh_nawale the problem is that USA is in the Location_Arr[3], so it means that I need to leave it there and put the other countries into Location_Arr[3] and leave the
in the Location_Arr[2]. I have no idea on the script, because I’m a beginner(((
States


Hey @Felis90, is this the output that you expect

The error is due to using Square brackets instead of round brackets
2

I have also uploaded my workflow in previous answer for your reference. You can download it and import it in KNIME analytics platform.

It seems the same as yours… but again the error… when I delete the word “column” the values become Location_Arr[2] in the required column… if I leave it, then I have the error…see the pic 1. The second expression seems ok, see the pic 2.
I need to understand why, because I’m a student… and this is my home task… I need to do it…


hey @Felis90,

You are missing the double quotes in your syntax

Use this

column(“Location_Arr[3]”)==“USA” ? column(“Location_Arr[3]”) : column(“Location_Arr[2]”)

@yogesh_nawale again…. But another one… I have already copied and pasted your text…

UPD: I used ‘ instead “ and everything has been executed)))

Hey @Felis90,
Yes you can also use single quotes. Sometimes double quotes gives error depending on the expression used. This happens because of how the node interprets different types of expressions or contexts. However, KNIME is more consistent and predictable when using single quotes for string comparisons or literals.

Did you get the required output?

@mwiegand i tried to implement this approach, but not clearly understand what script shall be written there(

If the same as @yogesh_nawale suggested, I will try again taking into account my mistakes made w.r.t. punctuation ‘ instead “…

Hey @Felis90,
Can you upload your workflow with some dummy data so that we can see where the problem is ?

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