Data table to dictionary, Dictionary key based on column names

Hi @Akhil_Raveendran

→ Read Range Workbook:


Output-> dt
→ Use Below syntax in assign:

outputDict= dt.Columns.Cast(Of DataColumn)().ToDictionary(Function(col) col.ColumnName, Function(col) dt.Rows(0)(col))

outputDict is of DataType System.Collections.Generic.Dictionary(System.String,System.Object)
→ Use For Each loop

For Each kvp in outputDict
     Log Message-> kvp.Key + ": " + kvp.Value.ToString
End For Each

Output:
image

Sequence.xaml (9.2 KB)

Hope it helps!!

2 Likes