Covert a Column from datatable to string which are in comma separated format

Hello,
I have a datatable have names like
A
B
C
D
E
And i want to convert it to A, B, C, D, E. Please help with this. Thanks in advance.

@elasador.pune
Use "Output Datatable "Activity and write it to the String variable. This will give you the desired output.

Hi @elasador.pune,

To achieve this you can do like,

Suppose your values are in the datatable DT and the column name is Column1 so to achieve result like A,B,C,D
you can do something like

String.Join(",",DT.AsEnumerable().Select(function(arg as datarow) arg("Column1").ToString))

here DT is your datatable variable, assign this query to a variable and print the result you will get the result.

Cheers !!

2 Likes

Hi i tried this, it doesn’t work, i got System. Object() as output. And other method that i can use?

Hi i tried this as well. This gives each value on a new line

Hi,

Can you share your xaml and input file or any of the both.

Thanks

Hi @elasador.pune

U can get the answer for this by simply extending the @elina answer

Like after output the datatable using output datatable activity , let’s say output is stored in

result variable.

so.use the below assign activity for ur case,

result = String.Join(“,”, Split (result, Environment.NewLine))

This will give ur results

Hope it helps you

Regards

Nived N :robot:

Happy Automation :relaxed::relaxed::relaxed::relaxed::relaxed:

use this
String.Join(","c,dt.AsEnumerable().Select(function(x) x.Field(Of String)(“Column1”)).ToArray())

Column1 is the name of your column
dt is the varaible name of datatable

output is
A,B,C,D,E

use this (assign to a string variable)
String.Join(","c,dt.AsEnumerable().Select(function(x) x.Field(Of String)(“Column1”)).ToArray())

Column1 is the name of your column
dt is the varaible name of datatable

output is
A,B,C,D,E

3 Likes

This works :+1: thanks a lot.

1 Like

Thanks for replying, the previous method worked out.

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