Compering dictionaries of unequal data

In short:
Is there a way to populate Dict1 with data from Dict2, using common keys, while leaving the rest of the Dict1 as is? See below:

Longer explanation:
I am trying to manage data of inconsistent, and changing length, process it and then push it back to Revit as values. I have managed to collect the data, now I would like to normalize it to the same size, leaving zeros if the object does not exist on given level. Example from the picture above: I would like number from Dict2 (in red) to be pushed to Dict1 under the correct dictionary, leaving the other value (L) for the same record unchanged. Dict1 consists of 4 layers and that will remain constant, the amount of items on each level may vary.

This should help you get started. I only did up to 2 levels of dictionary but the concept should be the same. If you can upload your graph with data, I can try to get it to work with your levels.

1 Like

Thank you for your help. I have played with your idea and was able to produce desired outcome. Although it does have its limitations. Because the dictionaries are of different length calling values produces null output - hence warnings. In this particular example I do not mind since whenever there is null there should be zero, so I can just overwrite them easily. But ideally I would prefer to leave the values from the Dict1 as they are. Additional functionality would be to leave the keys values as they are.

I can’t send you my file but I will try and replicate the data structure and provide the file later on.

The difference between our graphs is that I never use Dict1 as the keys for Dict2, rather I do the opposite. That is where the null values come from. Let me know when you can replicate the data and I’d be happy to try my hand at it.

I do not seem to get it right. Here is mockup file: dict.test.dyn (42.6 KB)