I have a Dictionary(string,string) and datatable where in one column i have in random order same values as Dictionary key-values are. How can i populate column 2 based on key-values in col1? To illustrate my problem, here’s a output i’d like to have.
I tried to convert dictionary to datatable and merge/join, no luck there.
Considering the image provided to be the Output, Check the below Expression :
OutputDT = (From x In parametersDict
Let key = x.Key
Let value = x.Value
Let dictValue = key+", "+value
Select OutputDT.LoadDataRow({dictValue,key,value},False)).CopyToDataTable
Here, parametersDict is the Dictionary variable and OutputDT is a Datatable type variable.
OutputDT is to be prepared with the columns like shown below before the use of the Expression.
Thank you for this example. I am sure something of this nature solves my problem. What i forgot to mention is that i have two datatables that i try to merge into one. First one has dict keys/values and another has rest of the data including columns with the same name as in dict dt.
Sure, Here we have two sample excel- files that we read into datatable. Testinput.xlsx is converted into dictionary, Testinput 2.xlsx B-column should be targeted with dictionary values according to Company name column values. I cannot do this in excel directly. We have to build one datatable variable from these two and after that output to Excel.
Sorry for late reply. Problem got sorted like this.
Inner left Join dt1 & dt2 > for each datarow assign correct column > remove columns added from join step.