Hi all,
I have an excel in ColumnB I have some data like 001-1 or 002-2 I need to remove -1,-2,-3 from all the rows of columnB.Tge number before - must be there but -and number after - must be removed from all the rows in that column
How to do this. Can you please help me
1 Like
Yoichi
(Yoichi)
March 16, 2024, 8:07am
3
Hi,
How about the following?
Please set Text format at the cell using FormatCells activity to prevent to omit 0.
Regards,
Sorry i cannot use foreach row as I have huge data
lrtetala
(Lakshman Reddy)
March 16, 2024, 8:24am
5
Hi @0bb4628e217fd43ac86ac9294
Try this
(From row In DT.AsEnumerable()
Let newValue = System.Text.RegularExpressions.Regex.Replace(row.Field(Of String)("ColumnB"), "-[0-9]+$", "")
Select DT.Clone.Rows.Add({row.Field(Of String)("ColumnA"), newValue})).CopyToDataTable()
Cheers!!
Hi,
Use below linq:-
Assign activity:
dataTable = (From row In dataTable.AsEnumerable()
Let newValue = row.Field(Of String)(“ColumnB”).Split("-"c)(0)
Let newRow = row
Select newRow.SetField(“ColumnB”, newValue)).CopyToDataTable()
Thanks
Yoichi
(Yoichi)
March 16, 2024, 11:55am
8
Hi,
Another approach:
How about the following?
dt.AsEnumerable.ToList.ForEach(Sub(r)
r(1)=r(1).ToString.Split("-"c).First()
End Sub
)
Sample
Sample20240316-2a.zip (6.9 KB)
Regards,
1 Like
Thank you all for your help on time
system
(system)
Closed
March 19, 2024, 1:27pm
10
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.