Copying Datatable to a single row of new datatable

Hi, i am looking to create a new datatable from an existing datatable but unsure how to convert this as i am only just starting to learn UiPath :slight_smile: any help appreciated

Typo on the Prod6 Code6 should be Prod5 Code5 :slight_smile:

prepare the target datatable with the generate datatable activity and configure the columns

then use dtTargetVar.NewRow to get an empty new row
Fill it up with a help of for each row and unsing the index out from for each row
add it to tatget datatable

we can also dynamize it
partly doing it with LINQ

1 Like

Something like this?


input Data:

Dynamic creation of the target datatable Structure:


Preparation / datarow value population / adding to target datatable:


Find starter help here:
Transpose_dtKeyValue-NonLINQ.xaml (10.9 KB)

1 Like

How about looping the first datatable and using ‘add data column’ activity for each row values. You can form the column name by incrementing the counter as mentioned already. Then you can assign the row values from the existing first 2 columns to these 2 new columns in each iteration.

Sruthi YNM

Perfect, this worked! thank you very much Peter :slight_smile:

I needed to find a different approach for this, could anyone help for the problem below, i need to join together two datatables with the columns intersecting:

Thanks in advance for any help :slight_smile:

a better would be to have scope this topic to case and provided solution.
Closet it if possible by marking the solving post as solution

Open a new topic for your last request and get support individually on the second request. Maybe you can share sample data in a format which allows us to better identify what is meant. e.g. only 1 row per datatable representing column headers or additional data als representing values


Ok Thanks closing this one off

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