Find empty column name in datatable

Helo all! I have a list with columns name for check, for example {“Name”,“Age”,“City”}
And data table with many columns and rows, not only Name,Age,City.
I need to check each row and find which column from my list is empty and print index.

For example:
index 3, columns Age
index 5, columns Age,City

Is there a best practice for solving this problem ?

Hi @Arettu63

→ Read Range Workbook
Output-> dt
→ Use below syntax in Assign

columnsToCheck= {"Name","Age","City"}
List= (From row In dataTable.AsEnumerable()
                Let index = dataTable.Rows.IndexOf(row)
                Let emptyColumns = columnsToCheck.Where(Function(col) String.IsNullOrEmpty(row(col).ToString())).ToList()
                Where emptyColumns.Count > 0
                Select "Index " & index.ToString() & ", columns " & String.Join(",", emptyColumns)).ToList()

columnsToCheck is Array(System.String) and List is of DataTyp System.Collections.Generic.List(System.String)

Regards

1 Like

Hi @Arettu63

Input:

Output:

Regards

2 Likes

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