Hi,
I want to filter for empty cells in a column and get the row Index of these rows from the original data table (so I can use the row index in a write cell activity).
Hi,
I want to filter for empty cells in a column and get the row Index of these rows from the original data table (so I can use the row index in a write cell activity).
Hi,
Can you try the following expression?
arrInt = dt.AsEnumerable.Where(Function(r) r("ColumnName") is Nothing OrElse String.IsNullOrEmpty(r("ColumnName").ToString())).Select(Function(r) dt.Rows.IndexOf(r)).ToArray()
This returns row index value of empty cell (0 based) as Int32 array.
Or, do you also need filtered datatable? If so, the following will work.
dt.AsEnumerable.Where(Function(r) r("ColumnName") isnot Nothing AndAlso (not String.IsNullOrEmpty(r("ColumnName").ToString()))).CopyToDataTable
Regards,
Hi Yoichi, thank you very much, your code works great!
Whats the difference between Nothing and Null/Empty and why do you ned to convert Null/Empty to String?
Thanks!
Hi,
If there is possibility specific item of the row is Nothing, it’s better to check it’s Nothing or not, because if it’s Nothing, row(“Column”).ToString (for exmaple) throws exception.
Then we can check row(“Column”).ToString is empty string or not without exception.
Regards,
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.