Concatenate cells into a paragraph with column names and formatted text

Hi, I am trying to concatenate text from multiple columns into a formatted cell (see below). So far I am here join($column1$,"\r\n",$column2$,"\r\n",$column3$) using String Manipulation node, but still missing a way to insert column names and hopefully add text format.
Suggestions?

ID Start date Name Last name Notes
111 May-01 Jane Welch ID: 111
Start date: May-01
Name: Jane
Last name: Welch
112 May-05 Jack Williams ID: 112
Start date: May-05

Name: Jack
Last name: Williams

Update:
I used a column rename node to add the columns as variables. I am not sure if this is the most efficient way to do get to the desired result but I am one step closer

@JulioCesar , new column is a default name for String manipulation node. Just change it to Notes.

Hello JulioCesar,
Maybe you can use “extract column header” node and “table row to variable” node instead of column rename .
From the variable you can get the column names.

Though it won’t be completely dynamic, it might help you

Hi @izaychik63, I didn’t mean renaming the column but writing a column name and its corresponding value inside a cell.

Yes, but then I duplicate the number of columns I have on my table.

@JulioCesar the white fields would contain the content of the variable after the node has finished so your flow variable

“111” would contain whatever old name you have put in for the first column you tried to rename. You can then use that.

If you want to set a name from a flow variable you would have to use the grey fields to the left. If you want the new name you would have to use that line.

But maybe we do not fully understand your tasks. Maybe you can provide an example in a workflow and explain how the result with the renamed columns should look like.

I think this can help

Flow
image

Input
image

Output
image

Expression

In the end however, you need to manually update the column expressions node if a new column is added

2 Likes

Hi @JulioCesar , alternatively, you can use Columns to JSON which will give you something in the same format that you are looking for, and it’s dynamic as in you don’t have to change anything if your table changes (new columns, less columns, it does not matter).

Just plug it to your data:
image

Input data:
image

Results:
image

And for fun, I added 2 extra columns:
image

Re-ran the same node without any modifications, and I got this:

You can do some cleanups if you really want the format that mentioned. You can use the String Manipulation:
image

You can for example convert the JSON to a string like this:


string($JSON$)

Or even clean up the JSON formatting completely:

removeChars(replace(replace(string($JSON$)
  , "\"", "")
  , ",\r\n", "\r\n")
  , "{}")

Results:

Here’s the workflow: Concatenate cells into a paragraph with column names.knwf (8.8 KB)

8 Likes

This is indeed a more elegant way to do what I was originally attempting, thanks.

Thanks, super creative with the JSON cleanup

2 Likes

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