My datatable has about 53000 rows and 13 columns. One of the columns is an ID and I would like to remove invalid IDs and remain with valid IDs that have 8 string characters.
Manually, I have determined that the invalid IDs are about 200.
How can I loop through the rows to find and remove these invalid IDs in the shortest time possible?
I want to remain with the valid IDs in a datatable so I can perform other actions on them. The invalid IDs will be emailed to a system admin for remediation.
We do feel that with a combination of Regex / StringCheck and LINQ we can do like
Assign Activity (valid Rows DT)
dtValidRows =
(From d In yourDataTableVar.AsEnumerable()
Where Not isNothing(d("YourColName"))
Let n = d("YourColName").toString.Trim
Where Not String.IsNullOrEmpty(n)
Where n.Length.Equals(8)
Where System.Text.RegularExpressions.Regex.isMatch(n,"[A-Za-z0-9]+")
Select r = d).CopyToDataTable