Merge Data Issue

Hi…

i am tring update the value in excel sheet… has input column Name…

dt1

image

dt2

image

i am using merge datatable acitivity i got output

Expected Output.
i want this output not above one…

image

Thanks
Shyam

@Shyam_Pragash It looks like you want to write the data between first and last column. Did you try with write range or append range activities

hey

merge datatable does not work like that…
you might use write range and specify the start and the end of the columns.

regards

Hi…

i having two datatable…

??

Thanks
Shyam

Option 1: fillup Excel sheet

  • use dt2 for a write range with a range offset to B2 and AddHeaders set to false / Unticked

Option2: datatable manipulation with LINQ

Assign Activity
LHS: dtMerged | DataType: DataTable
RHS: dt1.Clone

Assign Activity
LHS: dtMerged
RHS:

(From i in Enumerable.Range(0,dt2.Rows.Count)
let r1 = dt1.Rows(i)
Let r2 = dt2.Rows(i)
Let ra = r2.ItemArray.Append(r1.ItemArray.Last()).Prepend(r1.ItemArray.First()).toArray
Select r = dtMerged.Rows.Add(ra)).CopyToDataTable

Option 3: similar to the LINQ we can reconstruct the dt1 Itemarray and update each dt1 row within a for each row activity and using the index output for grabbing the dt2 data

Hi @ppr

in between the merge data cell of dt1 having mutiple columns.

i think column Name based query to update the value and get overall dt1 data.

Thanks
Shyam

May we ask you elaborate more on this feedback, as we dont get it in detail? Thanks
Which suggested approach did you focused?

Continuing the discussion from Merge Data Issue:

Hi @ppr.

Today i have received two reports.
One is Manual report is having empty columns (dt1) – More than 150 Cols
Seconds report is System Generated report (dt2) – Min 5 to 8 Cols

i have merge the data under the columns Name of dt2 to dt1.

To be update Columns Name both are same dt1 and dt2

Thanks
Shyam

we would prefer a more close dialog as questions are remaining open:

maybe following dynamic logic will work with the strategy if column is present in dt2, then take the value there. Assumption dt2, dt1 column names are the same

--

Edited: reworked statement below within starter help XAML

Hi… @ppr

i got Complier errors

image


grafik

dt2 has more rows as dt1 in case of this can happen, then add some additonal logic for detecting, handling this

find starter help here:
Merge_DT2Col_IntoDT1_WhenPresent.xaml (8.4 KB)

1 Like

Hi @ppr

The Code is working fine your are sent xaml file…

But i have main source xmal file to add this code. i got the error…

image

i imported the Namespce…

UiPath.UIAutomationNext.Models.ExtractData
System.Data

Still i am getting error.

can you tell me how to fix it…

Thanks
Shyam

Hi All

Thanks :slight_smile:

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