Help with formatting Col output from a DT

I have a workflow that should format an out_argument (out_Ids) so the formatted out_argument looks like this:
future  ids

Currently, my workflow is having that out_argument looking like this:

The formatting tricks I tried have failed, need some help here. Attached is my workflow.
convertColumnsToInClause.zip (11.7 KB)

Hi,

How about the following expression?

out_ids = String.Join(",",System.Text.RegularExpressions.Regex.Matches(out_Ids,".{1,2}").Cast(Of System.Text.RegularExpressions.Match).Select(Function(m) m.Value))

Or the following may be simpler.

out_ids = System.Text.RegularExpressions.Regex.Replace(out_Ids,"(?<=\d\d)(?=\d)",",")

Regards,

@Yoichi Thanks for the suggestion but I think you read my ask wrong.
Currently the output of out_Ids is written out one record in each row as shown below

The behavior I want is that all the IDS are written on the same line but separated by a comma, for example, it should look like:
21056964,21056895,21056931,21056953,21056920,21056975,21056964,21056895,21056942… till the last record

Hi,

All right. Can you try the following xaml file?

convertColumnsToInClause.xaml (10.7 KB)

Note: I fixed your xaml regarding reference to DataSetExtensions because of enable LINQ.

Regards,

1 Like

@Yoichi
Thanks!!!
I have a use case to also output the same variable to return as an array of String so the output is now like this:

{β€œ21056964”,β€œ21056895”,β€œ21056931”,β€œ21056953”,21056920," till the last record}

Hi,

Can you try the following expression?

arrStr =  dt_colsFromExcel.AsEnumerable.Select(Function(r) r("ID").ToString).ToArray()

Regards,

@Yoichi

Thanks for that suggestion, I did modified my workflow but it does not print out the out_arg as String array. Instead, it does print them as shown below.

attached is the updated workflow, I may be missing something.
convertColumnsToInClause.zip (12.0 KB)
Thanks

HI,

It’s unnecessary to use ForEachRow activity. If you want to check content of the array, can you try to set Break point and check Locals panel OR use ForEach against the array then print each item.

Regards,

@Yoichi
Thanks I saw that, thanks

I wanted the out_ids to come out as a String Array like this
{β€œ21056964”,β€œ21056895”,β€œ21056931”,β€œ21056953”,21056920," till the last record}

so I called the Stting.Join on it as seen here:
image

However, it does not output the out_arg as a String Array, instead, it came out like this:

How do I manipulate it so the output comes out as a String array with the { } ?

Do you mean you need {β€œ21056964”,β€œ21056895”,…} as single String?
If so, the following will help you.

"{"""+String.Join(""",""",dt_colsFromExcel.AsEnumerable.Select(Function(r) r("ID").ToString))+"""}"

Works better- little code

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