# Replace or remove every second bracket of String

Hej there,

i got a pretty big String of lat and lon coordinates in brackets. Now i would like to remove every second bracket to reduce the length of the string.
So far i unfortunately couldnt find a solution. Example in the following:

A) → B)
A)
[53.625049437,9.983927646],[53.62505694,9.98394286], [53.625065775,9.983960775],[53.625075446,9.983980385],[53.625035645,9.98389968]

B)[53.625049437,9.983927646], [53.625065775,9.983960775],[53.625035645,9.98389968]

Br,
Nils

2 Likes

Hi @NilsAhr and welcome to the KNIME forum !

You could do in this order as follows, just using KNIME nodes :

1. Cell Splitter : Convert your long string into a list, splitting the string by the comma separator as delimiter. Make sure that the resulting format you chose is “List”. This should generate just one extra column.
2. Ungroup : Ungroup this column. The result should be as many rows as coordinates you have in your initial list.
3. Math : Calculate whether the row index is odd or even and create a column with this result, i.e. 0s (even) and 1s (odd).
4. Rule-Base Engine Splitter : Keep only ODD rows (RowId is odd).
5. GroupBy : Group the remaning rows using GroupBy node and aggregate using “Concatenate” with a comma separator.

This should do the trick

Hope this helps,

Ael

5 Likes

Hej Ael,

thanks a lot!
Problem is solved!

Br,
Nils

3 Likes

Hi @NilsAhr

Great news. Glad it worked !

If you are happy with this solution, would you mind please to validate my answer ? There is a box to check for this. It will help people to search and reach the “solved solutions” more easily

Best wishes,

Ael

4 Likes

Thanks @NilsAhr for validating !

Best wishes,

Ael

2 Likes

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