Community Conundrums are live! Learn more

New line Delimiter for Concatenation in Prepare Recipe

Level 1
New line Delimiter for Concatenation in Prepare Recipe

I have few columns in a table and I need to concatenate the date from all these columns into a new Column. I am using the Concatenate Column feature but I need all the values from each column in a new line under the new column. What might be a possible delimiter for this scenario. Can someone help. I have tried \n but did not help.

0 Kudos
7 Replies
Dataiker
Dataiker

Dasrana,

Can you give an example of what your data looks like and what you trying to turn it into in your Prepare recipe?

Grant

0 Kudos
Level 1
Author

I have 5 string columns in  a Dataset. I have tried to create a Prepare Recipe on this dataset to use Concatenate. I have selected all the 5 columns in the concatenate and want to load the concatenate data in a new Column but my requirement is each of string from these 5 columns should be in a new line under the new column. So I am not sure what should be a good delimiter to get a new line for each of the concatenated strings.

0 Kudos
Level 1
Author

Col1                                                                Col2                                                            New Concat Column
Hello                                                           Client                                                                      Hello
                                                                                                                                                       Client

Here you see the New Concat Column should have strings from Col1 and Col2 but in new lines

0 Kudos
Dataiker
Dataiker

Hi,

This is not possible with the "concatenate" processor, but you can use a formula:

 

[col1, col2, col3].join("\n")

 

DSS will not actually display multiple lines in the explore window, and will show a special mark instead, but an export (CSV or Excel) would have it.

As usual, if your column name is not "simple" (if it contains spaces for examples), replace col by strval("my column") - don't forget the quotes.

0 Kudos
Level 1
Author

Thanks Clement. I did achieve that with Formula but was looking for the Concatenate to work as well. Are you from Dataiku. Any plan to put this feature?

 

Regards,

Rana

0 Kudos
Level 1
Author

Hey Clement - One other help required - can you please tell me if few of my columns in that concat has Null records, how can remove those null lines in my final concatenated value.

 

Thanks,

Rana

0 Kudos
Dataiker
Dataiker

Hi,

I am from Dataiku indeed 🙂 We'll be taking good note of your feature request and we'll be adding it to our development backlog.

To filter out nulls, you must:

* Start by building the array (using [] construct)
* Filter nulls out of the array (using the "filter" function and the "isBlank" function)
* Join the array (using the "join" function)

Which means your formula will look like:

 

filter([col1,col2,col3], v, !isBlank(v)).join("\n")

 

With this result:

Clément_Stenac_0-1580455271203.png