jntrk
(jntrk)
December 21, 2021, 3:56pm
1
Hey everyone,
I have 2 datatables with 1 column. First dt has the column named “item”, second datatables column is named “number”, I read them seperately from excel and I want to add the 2 datatables together. To example it
DT1:
item
15
3
2
1
5
DT2:
Number
7
8
9
4
6
These 2 tables always will have exact same number of rows. So i want to join them or merge them as
item ** Number
8 *******7
3 *******8
2 *******9
1 *******4
5 *******6
Any suggestions?
arivu96
(Arivazhagan A)
December 21, 2021, 3:59pm
2
Hi @jntrk ,
Use join data table activity to join 2 tables
Refer below link for join two tables
Hi All,
Use below code to remove empty row from the table.
DataTable name->DataTableName
Use assign activity
DataTableName=DataTableName.Rows.Cast(Of DataRow)().Where(Function(row) Not row.ItemArray.All(Function(field) field Is DBNull.Value Or field.Equals(""))).CopyToDataTable()
Re-usable Component pass Parameter as datatable you will get the answer.
RemoveEmptyRows.xaml (8.5 KB)
Remove rows based on particular column is empty.
DataTableName.Select("Convert(column3, System.String)< >''"…
Regards,
Arivu
jntrk
(jntrk)
December 21, 2021, 4:05pm
3
the join table you sent wont work because my tables dont have anything in common. I just need to get them together as 1 datatable
arivu96
(Arivazhagan A)
December 21, 2021, 4:05pm
4
Hi @jntrk ,
Use join data table activity
UiPath.Core.Activities.JoinDataTables Combines rows from two tables by using values common to each other, according to a Join rule, which is specified in the JoinType property. Properties Common DisplayName - The display name of the activity. Input...
Regards,
Arivu
prasath_S
(prasath S)
December 21, 2021, 4:06pm
5
Hi @jntrk
Write both the datatables to the Excel and read the excel again and store that to the datatable.
Read range excel 1 - dt1
Read range excel 2 - dt2
Write range dt1 - A1
Write range dt2 - B1
Read range new excel - dt3
Thanks
jntrk
(jntrk)
December 21, 2021, 4:08pm
6
Yea this works absolutely but i thought maybe there is a more efficient way.
jntrk
(jntrk)
December 21, 2021, 4:09pm
7
I dont have a join condition.
ppr
(Peter)
December 21, 2021, 4:33pm
8
we can do it with a side by side merge (Not merge activity)
find a first introduction on examples here:
@Kavya_Mamidishetti2
Create an empty datatble with the three cols with the help of Build datatable - dtMerged
then use an assign activity:
left: dtMerged
right
(From x in Enumerable.Range(0, dt1.Rows.Count)
Let ra = new Object(){dt1.Rows(x)(0),dt2.Rows(x)(0),dt3.Rows(x)(0)}
Select dtMerged.Rows.Add(ra)).CopyToDataTAble
Feel free to use ColName instead of ColIndex
in case ofg the datatables will have different row counts we can adopt also have a look here:
1 Like