Creating a Dictionary of list from excel

Hi Guys,

I am working on a process which has a master excel. This excel contains around 200K+ rows and 50+ columns. The first column is unique for all the row. In the process we are passing the data table to each workflow to get the result.
What I am thinking is to convert the whole data table to a dictionary of key being the unique column and its value being the rest of the data in a list.
But I am facing some issues in creating the dictionary. Need help on it.
I have attached a sample flow that I am working with.
Sample.zip (10.6 KB)

BR
Devbrath Rajkhua

1 Like

Actually dictionary will be a key value pair. So, it will have a key and a value based on the key @Devbrath_Rajkhua

You can’t add more than one value to a key I hope. Can you explain what are you trying to do?

1 Like

Hey @HareeshMR
What I am trying here is to create a dictionary(System.Object, System.Collections.Generic.List<System.Object>).
The keys will have the unique value of the row and the list will contains the rest of the data for the row. This way, it will be more faster to get the data for a unique value compared to iterating through a data table.

1 Like

Yeah, that was a great thought @Devbrath_Rajkhua

So, You need to add the data to a list variable except the key name and then create and initialize a dictionary as dictionary = new dictionary( of object, System.Collections.Generic.List<System.Object>)

Then use add dictionary and assign the key and the list as value which you created above. I hope you are missing something here

I haven’t opened your workflow

1 Like

Hey @HareeshMR

Exactly the same thing I have done in my flow but for some reason after adding the values to list, when I assign the list to dictionary I am getting below exception.

Assign: Cannot create an L-value from the given expression with property ‘set_Item’ because the target object is null.
Still not sure what the error is :thinking::thinking::thinking:

BR
Devbrath Rajkhua

1 Like

The error is, you haven’t initialized the dictionary @Devbrath_Rajkhua

Have you assigned this to the dictionary variable you have created before assigning the values to dictionary ?

1 Like

Actually we have variables to work with dictionary activities @Devbrath_Rajkhua

But I don’t see you are using them in the workflow. But the process you are trying is also works.

If you want to work with activities try installing this package

Microsoft.Activities.Extensions

1 Like

Hi @Devbrath_Rajkhua

You can use this componet created by @sandeep13 to convert your Excel to a Dictionary:
https://go.uipath.com/component/convert-excel-to-dictionary-key-value-pair

Thanks and regards.

4 Likes

Hey @HareeshMR

Yeah silly mistake of not initialising the dictionary :man_facepalming::man_facepalming:.
After initialising the dictionary, it is working fine.

Thanks :slight_smile:

Yeah @Devbrath_Rajkhua

Glad you got solution.

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