here i have datatable abcdt with column name CPT
i want my output in column CPT as values before spance
Hi @Jorie_02
→ Use the read range workbook activity to read the excel and store in a datatable called Input_dt.
→ Use for each row in datatable activity to iterate the each row in the datatable.
→ Inside for each insert Assign condition to get the output.
- Assign -> CurrentRow("CPT") = CurrentRow.toString.Split(" ").First
→ Write the Input_dt to same excel by using write range workbook activity.
Hope it helps!!
I want to make this change using linq in my datatable
Like it will split and take value before space
I have update the process steps above and check the workflow here,
Workflow -
Input -
Output -
Hope you understand!!
Hi @Jorie_02
→ Use Read Range Workbook to read the excel and store the output in a datatable.
Input:
→ Use the below code in Assign activity:
out_dt= dt.Clone()
out_dt= dt.AsEnumerable().Select(Function(row) row("CPT").ToString.Split(" "c)(0)).Select(Function(value) out_dt.Rows.Add(value)).CopyToDataTable()
Note: out_dt is of datatype System.Data.DataTable.
→ Use Write Range Workbook to write the out_dt back to excel
Output:
Workflow:
Regards
@Jorie_02
Welcome to the forum
similar to
we can do:
Assign Activity
dtCleansed | a DataTable Var = dtOrigVar.Clone
Assign Activity:
dtCleansed =
(From d In dtOrigVar.AsEnumerable
Let cpt1 = d(0).toString.Trim
Let cptm = System.Text.RegularExpressions.Regex.Match(cpt1,"^\d+")
Let cpt2 = If(cptm.Success, cptm.Value,cpt1)
Let ra = new Object(){cpt2}
Select r = dtCleansed.Rows.Add(ra)).CopyToDataTable()
@Jorie_02
For LINQ learning have a look here:
[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum
For Regex Starter Help:
[CheatSheet] - System.Text.RegularExpressions | RegEx - News / Tutorials - UiPath Community Forum
And RnD and prototyping we can quickly within immediate panel
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.