How to merge 5 or more datatables into single datatable

Hi,

There are 5 excel files, reading them and storing into each datatables. now we have to merge them into a single file. How to merge them.

Regards,

Hey @raju_alakuntla ,
U Can use Merge Datatable Activity
image

Hi @raju_alakuntla ,

We sometimes get confused with the words Merge and Join, So we ask you if you could provide us with a Sample Data set and its Expected Output, so that we can provide the Proper suggestions.

can we add 5 datatables with single merge activity?

I have 5 excel files where the “columns(Name, Reason and Additional comments )” are same in each file. we need to merge the data of Reasons and Additional comments for each person from different files into one file.

Here is the sample data.

Hey @raju_alakuntla ,
Yes you can do it by using a for each loop

Configure the loop to iterate through a list of DataTables (DataTablesList) that includes DataTable1, DataTable2, DataTable3, DataTable4, and DataTable5.

Inside the loop place a merge Datatable activity
And source would be your currentitem and destination will be a datatable of your choice

After the loop write the destination datatable to excel

Hope it helps you out!

can you suggest me for which activities should I used to loop through the data tables.

Hi @raju_alakuntla

You can try this below method to loop through datatables

I am not able to get the “add to collection” activity. Is there any package to install to get it?

@raju_alakuntla

You can try this way also

New List(of DataTable)({DT1,Dt2})

image

getting this error

“Merge Data Table: Object reference not set to an instance of an object.”

@raju_alakuntla

Make sure data table is not empty

I am not getting the desired output. I only need the data after merge but In the final output, its merging properly but again its writing the excel1, excel2, excel3 and excel4 data.

How to avoid this.