Hi everyone
I have a dictionary( of string, datatable).
I need to populate a datatable( keys, dictionary value).
I am able to get the value , not able to access the keys .
Thanks
Rajeena
Hi everyone
I have a dictionary( of string, datatable).
I need to populate a datatable( keys, dictionary value).
I am able to get the value , not able to access the keys .
Thanks
Rajeena
you can iterate over the dictionary and accessing key and value by following:
For each activity | kvp in yourDictVar | TypeArgument: KeyValuePair(Of String, DataTable)
This is what I have ,
I do have the key .
In the outputdt →
input-> dict_InvoiceTable(key)
output ->strInvNo
in the excel , I need the entry as follows : where the invoice number is the key and the other fields from dictionary
Thanks
kvp in yourDictVar - use kvp instead of key for the loop variable name
kvp.Key
kvp.Value
as mentioned aboe for the access
when the datatable is to enrich with the dictionary key information then update the column by using a for eacch row befor writing it to the excel
not getting .key and .value with loop var
share a screenshot from your type argument from for each activity, thanks
Also kindly note following:
was not mentioned, remove Keys and change typeargument as mentioned above to KeyValuePair(String, DataTable)
removed the keys
adddata row {kvp.key, kvp.value}
tried , excel looks the same as above
please reread the answers from above
vs
For each | …
Hi @Rajeena_M ,
This looks to be quite understandable, but for confirmation, Could you Provide us with Example data, as to What would be the Key
and the Value
of the Dictionary.
If it is the Invoice Number and Datatable, Could you show us a Visual on one of the Key Value Pairs.
Or According to this Image, Invoice Number is the key, Where Other Columns are from the Datatable and you would need the Output like the Above Image ?
I have used DU to extract the tables, its items table of a an invoice.
Table from Dataset
Column A(invoice number) is not from the table, extracted using ML extr
Then added to dictionary (string , datatable) → inside the foreach of DU
dict_InvoiceTable(invoice number, datatble)
I am using the Dictionary for further activities.
and write line to see the output.
Just wanted to see it in excel , as in the above pic.
Please find the Example Workflow Below :
Combine_DT_in_Dictionary.zip (10.3 KB)
We can keep the Input data as required By Preparing the Input Data, then Work on the Output format that is Required.
We use the Following Linq Query to Get the Data in the Form Required :
(From p In tempDT.AsEnumerable()
Group By x= New With { Key.a =p.Item("Invoice Number")}
Into Grp = Group Select tempDTClone.LoadDataRow ({grp(0)(0).ToString}.ToArray.Concat(Enumerable.Range(1,tempDT.Columns.Count-1).Select(Function(y)String.Join(Environment.NewLine,grp.select(Function(c) c(y).ToString))).ToArray).ToArray,False)).CopyToDataTable
We get the Output as below for the Input Data :
You would not need to Prepare the Input data as you already have the Dictionary(Of String, Datatable) available.
Let us know if you still face issues.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.