Search code examples
spotfire

Spotfire extract decimal numbers from string column


I have a string column that looks like this:

ColumnA
"POINT (10.203942930 45.2903203)"
"POINT (11.356898730 25.2548565)"

from which I would like to extract the numbers and create two separete columns:

column1
10.203942930
11.356898730

column2
45.2903203
25.2548565

I have tried RXReplace, but I get one single number which is not decimal...

RXReplace([col], "[^0-9]", "", "g")

Any help will be really appreciate it.

Thanks in advance.


Solution

  • @thundermils - Please try this solution.

    Step 1: Create a calculated column which separates text 'POINT' from "POINT (10.203942930 45.2903203)"

    left(right([Column A],Len([Column A]) - Find("(",[Column A])),-1)
    

    Now, separate the two numbers into two separate columns.

    Step 2: Create 'calc1' column with the below custom expression

    Trim(left([calc],Find(" ",[calc])))
    

    Step 3: Create 'calc2' column with the below custom expression

    Trim(right([calc],Len([calc]) - Find(" ",[calc])))
    

    Here is the final output:

    enter image description here