Merging two Datatable end-end

Hi ALL,

Please guide me in merging two datatables end-end. currently Merging is giving me null values for many fields.

For Example:
C1a NULL
C1b NULL
C1b NULL
NULL C2a
NULL C2b
NULL C2c

@Mohit_Sagar
Can you send the sample data table values and what is the connection between those data tables to merge? to merge data tables, there should be match in the columns.

1 Like

Merge Data Table will join like-Columns together, so if there are different column names it will add the column and leave blank fields for the other columns that didn’t match.

Append Data Table will join the tables together regardless of columns. (not recommended if columns are out of order in each table, but works if you set the ordinals correct)

@ClaytonM

How to append, we currently don’t have Append Datatable

My mistake. It’s Append Range. So it adds the table to the Excel file.
image

1 Like

If you want to append to an excel file, use the method ClaytonM mentions.

If you want to append dt2 to dt1 within UiPath only (not within excel), then first you must make sure that the structure of dt2 and dt1 are the same. You can do this by cloning dt1 with an assign activity dt2 = dt1.clone

Now that the structure of dt2 is EXACTLY the same as dt1, you can fill dt2 with data.

When you want to append, you should do a for each loop over dt2 datarows. Inside the loop, use the invoke method activity and ImportRows to dt1.

After performing the above, dt1 should have the data from dt2 appended to the end