Need to append two rows and store it in a single variable

I need to append two rows in datatable and store it in single variable
For eg: date value count
12/31/2020 14 3
12/31/2021 13 2

Output should be 12/31/2020 14 3;12/31/2021 13 2 should be stored in string variable

@sruthesanju

You can get the row in an array using an item array and using string.join you can join two arrays in a single variable.

Hi

Hope these steps would help you resolve this

β€”if the data is in a datatable named dt then use a output datatable activity where pass the dt as input and get the output as string variable named str_output

β€”then use a assign activity like this

str_final = String.Join(β€œ;”,Split(str_output,Environment.Newline.ToCharArray)).ToString

Cheers @sruthesanju

1 Like

Hi @sruthesanju

Let’s say the rows are in index 0 and 1 (row index)

Then use,

String.Join(" β€œ,dt1.Rows(0).ItemArray())+” ; β€œ+
String.Join(” ",dt1.Rows(1).ItemArray())

Regards,

Nived N

It considering the header also
I get the out as
Date value count;12/31/2020/ 13 4

1 Like

In that case use the below expression to remove the header

str_final = String.Join(β€œ;”,Split(str_output,Environment.Newline.ToCharArray).Skip(1).ToArray()).ToString

Cheers @sruthesanju

grafik
String.Join(";", {0,1}.Select(Function (x) String.Join(" ",dtData.Rows(x).ItemArray)))

within array you can mark the row index of all rows of interest

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