replace one row name(thaar) with row name(Audi) in excel in UiPath
Hi @Shravan_Pintu
Use Read Range activity and stored in variable dt.
Use the For Each Row activity to iterate through each row in the DataTable
.
Inside the loop, add an If activity to check if the row contains thaar
in the specific column.
row(0).ToString.Equals(“thaar”)
use an Assign activity Then part to replace the value in that cell with Audi
.
row(0)=“Audi”
I hope this will work
Thanks
You can attempt this in multiple ways
1 you can read this excel store result in data table
2. Use for each row active to iterate through data table
3. Now assume your for each row variable is current row
4. In the inside block add if condition like
5. Currentrow(cars).item.tostring.tolower.trim.euqals(“thaar”)
6. Then in if condition is true add the assign activity where on the left side pass currentrow(“cars”) = “audi”
You can achieve this by using linq also
Hope this was helpful @Shravan_Pintu
Use this LINQ in Invoke Code activity.
(From row In yourDataTable.AsEnumerable()
Where row.Field(Of String)("cars") = "thaar"
Select row).ToList().ForEach(Sub(row) row.SetField("cars", "Audi"))
Use find/replace activity and you can replace all or the cirst occurance with required value
Cheers
its replacing all banana fields with mango
i want to replace only one banana with mango
Any specific n th value like first/last or 2nd like this?
any banana field is fine,
output should be
2 bananas
1 mango
you have given row count so youa re searching for 3
just give “Banana” and “Mango” in valut to find and replace with fields respectively
cheers
Use this logic.
LINQ to print the counts
String.Join(", ", (From row In dtInput.AsEnumerable
From col In dtInput.Columns.Cast(Of DataColumn)
Group row(col.ColumnName).ToString.Trim.ToLower By fruit = row(col.ColumnName).ToString.Trim.ToLower Into Group
Select $"{fruit} {Group.Count}").ToArray)
Code:
TestProject (2).zip (60.0 KB)
Output:
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.