How can I efficiently delete rows with missing values in a DataTable?

Besides performing a “Filter Data Table” operation on all columns, are there any faster methods to delete rows with missing values in a datatable?

HI,

Can you try the following sample?

Filter out rows which has one blank at least

arrDr = dt.AsEnumerable.Where(Function(r) not r.ItemArray.Any(Function(o) o Is Nothing OrElse String.IsNullOrEmpty(o.ToString))).ToArray()

OR

Filter out rows which all blank

arrDr = dt.AsEnumerable.Where(Function(r) not r.ItemArray.All(Function(o) o Is Nothing OrElse String.IsNullOrEmpty(o.ToString))).ToArray()

Sample
Sample20240815-2.zip (3.4 KB)

Regards,

Hi,

I cannot open your sample file, possibly due to version issues, but the solution is effective.

I will remember to bring the software version next time, it was my oversight.


Your solution is super efficient! I really appreciate your warm-hearted help.

Regards,

1 Like

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