split does not recognize a comma as a delimiter for an array of numbers that has been converted

Henry Torres October 7, 2024

Hello! 

Looking for some assistance with the split function not recognizing a comma as a delimiter for an array of numbers.


I found the following SQL from the examples linked below: 

SEARCH / AS @a EX('Col 2'->split(",")) /
RETURN(@a->'Col 1' AS 'Col 1', _ AS 'Col 2') FROM T1

This will not work on the following table because they are all numeric characters

 

Col 1Col 2
Row 1111. 222
Row 2333
Row 3444, 555

 

if you proceed to modify the SQL to the following by converting 'Col 2' to strings, it still wont work  

SEARCH / AS @a EX('Col 2'::string->split(",")) /
RETURN(@a->'Col 1' AS 'Col 1', _ AS 'Col 2') FROM T1

The only way for this SQL to work is to enter a "character" into the values like so - notice the ' before the 111: 

 

Col 1Col 2
Row 1'111. 222
Row 2333
Row 3444, 555

 

My workaround to this issue is the following modifications to both SQL and data - i change from <,> to <;> and it will work. 

SEARCH / AS @a EX('Col 2'::string->split(";")) /
RETURN(@a->'Col 1' AS 'Col 1', _ AS 'Col 2') FROM T1
Col 1Col 2
Row 1111; 222
Row 2333
Row 3444; 555

 

 

Research:

Flatten an array in Table transformer macro 

Splitting cell values in a column to different rows 

1 answer

1 accepted

2 votes
Answer accepted
Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 8, 2024

Hi @Henry Torres ,

Seems that you are talking about our Table Filter, Charts & Spreadsheets for Confluence app and its Table Transformer macro.

Sometimes if we are talking about numbers, "," and "." can be mixed up with thousands or decimal delimiters, so you may adjust the first query from your post as

SEARCH / AS @a EX(TEXT('Col 2')->split(";")) /
RETURN(@a->'Col 1' AS 'Col 1', _ AS 'Col 2') FROM T1

Here we tell the macro to treat the cells' contents as text (not numbers or dates).

Henry Torres October 8, 2024

that did the trick! using the TEXT annotation and <, comma> as a delimiter gave me the correct output

thank you very much!

any additional recommendations on how to get the output to format correctly if a cell only had one value? 

 

For example:

Source Table

Col 1Col 2
Row 1111, 222
Row 2333
Row 3444, 555

Output Table

image.png

Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 2024

This row wasn't modified, so as the source table had the left align, such orientation was preserved for the untouched cells.

You may use the right align for the source table or add another Table Transformer macro on top of the first one with the FORMATWIKI function: https://docs.stiltsoft.com/tfac/cloud/changing-alignment-188620085.html

Like Henry Torres likes this
Stiltsoft support
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 9, 2024

Please note that as you are on Cloud, you'll need the Table Toolbox macro to nest macros. This macro was specifically developed to overcome the new Cloud editor limitations.

Like Henry Torres likes this
Henry Torres October 9, 2024

thank you very much for all the feedback it has been extremely helpful

Like Stiltsoft support likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events