How to transpose DT from normal form to horizontal form using loop?

I have a DT like this:

|Name|City|
|Harry|London|
|Ron|Edinburgh|
|Hermione|London|

I want output like:
|Name|Harry|Ron|Hermione|
|City|London|Edinburgh|London|

how to achieve this?

any help would be appreciated @ppr @NIVED_NAMBIAR any clue??

1 Like

Hi @cybzom ,

ColumnListVAr=( From row in dataTable.AsEnumerable() Select row(“ColumnName”)).ToList()**

1 Like

what is the type of columnlistvar? i want output in dt format bro… @Pradeep_Shiv

1 Like

Create a list of Object type or if you want it to be in String you can just convert it later.
and initialize like mentioned below
listOfObjects = New List(of Object)()

1 Like

sir can u provide sample workflow using dt? i am new and i don’t understand what ur saying… it would be of great help sir!!! thnx

1 Like

Sure Give me a minute!

1 Like

thanks so much sir!!! appreciate ur help!!! :slight_smile:

Hi @cybzom,

Hope this helps ColumnValue.xaml (6.5 KB)

Cheers

this works well but its only for one column… i have 2 columsn and I neeed the output to be in datatable format… how to achieve ths? i tried convert to dt but its not working… plz help… @Pradeep_Shiv

1 Like

Hi @cybzom,

go through this link, it may help you

no bro… i used a different approach… worked for me… thanks…

1 Like