Creating multiple dictionaries


#1

Hello,

I am trying to create a dictionary using assign activity. It works fine the first time but when I use it for another dataframe I am getting an error
Main has thrown an exception

Source: Dictionary EC

Message: An item with the same key has already been added.


#2

@MAHESH1 @arivu96 @Dominic


#3

@jamnanin

The keys should be unique, You can’t add duplicate values to Keys. Better check before adding whether the dictionary is having the the current key value.

Regards
Mahesh


#4

Hi @jamnanin,
If the Key is already present in the dictionary this error will occur.

You can check if condition before adding into dictionary.
dict.ContainsKey(keyName)

Regards,
Arivu


#5

do you mean to say the dictionary shoudl not contain keys with the same name? because the column i use to make the dictionary doesnt have duplicate values.


#6

@arivu96 but how will I know which key is same? because the column i use for making this dictionary has all unique values only


#7

@jamnanin
The Keys should not contains Duplicate values.

Regards,
Mahesh


#8

I doesnt… all the keys are unique


#9

Hi @jamnanin,

Before assign check the value are already exists in the Dictionary
dict.ContainsKey(keyName)

True-> key already exists
Else-> you can add the key into Dictionary

Regards,
Arivu


#10

You can overwrite existing key values with the Assign activity, but you just can’t add a new key with an existing key. So you can only do the Add part one time.


#11

but I am making a new dictionary all together. with all unique key values. I still get this error


#12

@jamnanin

How you are making new dictionary.
From Where you are taking values to add into the Dictionary.

Regards,
Mahesh