I have csv data Want to update value in Name column from Id column

Please check the screenshot
Check Id value and put in Name column
Ex.
ID(123)=Name(Jeff)
ID(444)=Name(John)
image

@Garyy

@Garyy

Try this in invoke method…send dt as in/out argument and dt1 as in argument and both needs to be assigned with same datatable variable in arguments

Dt.AsEnumerable.ToList.ForEach(sub(r) r("Name") = dt1.AsEnumerable.Where(function(x) r("ID").ToString.Equals(x("ID").ToString) and Not String.IsNullOrEmpty(x("Name").ToString)(0)("Name"))

Cheers

1 Like

Hi @rlgandu Solution is right but if ID row is blank then other column get above row value, i want only value which has ID
image

Thanks @Anil_G but i don’t want to use invoke method activity, you have any other solution

@Garyy

in for each loop take if conditin
Not String.isNullOrEmpty(CurrentRow(“ID”).ToString)
Perfrom the actions in true block
in else
Use break

@Garyy

Try the steps

  1. For each row in datatable dt
  2. Inside loop use if condition with String.IsNullOrEmpty(currentRow("Name").ToString)
  3. on then side use currentRow("Name") = dt.AsEnumerable.Where(function(x) currentRow("ID").ToString.Equals(x("ID").ToString) and Not String.IsNullOrEmpty(x("Name").ToString)(0)("Name")

cheers

1 Like

Try this below code . Hope it will be helpful.

Main.xaml (18.3 KB)

Can you help me with that error

@Garyy

Looks like I missed a bracket please check this

dt.AsEnumerable.Where(function(x) currentRow("ID").ToString.Equals(x("ID").ToString) and Not String.IsNullOrEmpty(x("Name").ToString))(0)("Name")

cheers

image
Getting this error

@Garyy

is DT having data ?

cheers

yes it has data
I shared the screenshot above

@Garyy

As per error looks like dt is null or empty

Cheers

@Garyy

Looks like there are few empty rows…before running this can you filter on the empty rows please

cheers

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