New line Delimiter for Concatenation in Prepare Recipe

dasrana
dasrana Registered Posts: 6 ✭✭✭✭

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.

Answers

  • GCase
    GCase Dataiker, PartnerAdmin, Registered Posts: 27 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

  • dasrana
    dasrana Registered Posts: 6 ✭✭✭✭

    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.

  • dasrana
    dasrana Registered Posts: 6 ✭✭✭✭

    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

  • Clément_Stenac
    Clément_Stenac Dataiker, Dataiku DSS Core Designer, Registered Posts: 753 Dataiker
    edited July 17

    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.

  • dasrana
    dasrana Registered Posts: 6 ✭✭✭✭

    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

  • dasrana
    dasrana Registered Posts: 6 ✭✭✭✭

    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

  • Clément_Stenac
    Clément_Stenac Dataiker, Dataiku DSS Core Designer, Registered Posts: 753 Dataiker
    edited July 17

    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

Setup Info
    Tags
      Help me…