I’m trying to build a dictionary which has strings as keys, but uses a record as the value.
I’m trying to convert a csv table into this dictionary, so I’m looping through the table to add each row as a record based on a column in the table. (Release date)
The reason for this method is to perform an easy check if a key in one dictionary exists in a second dictionary. If it does, I want to use the record value in the dictionary to take further actions. I’m open to other options if there is a better way.
It seems like each time the table loop happens, EACH key/value pair in the dictionary gets updated to the latest record values.
Is there a bug going on here, or is there something I’m not doing correctly with my setup?
Or is this an intended functionality? (hopefully not)
I’ll try demonstrating what I’m seeing here with screenshots.
Here is the setup I have for this.
I’m reading a CSV file into a table, then looping through this and adding it to a dictionary.
My first dictionary is setting the key as the release date and value as the current table records
My second one is setting the key as the release date and the value as the release quantity.
This one works as expected.
Here are some examples as the loops are iterating.
The first entry is good.
Both dictionaries have the correct values.
On the second entry, it seems like both records are modified to the current table row record.
My second dictionary has no issue, both keys have different values.
The first one seems to be getting updated as if it is not storing the record but rather the pointer to the variable.
I’ve also tried assigning the record to a different record variable before adding to the dictionary, but that resulted in the same issue.