Skip to main content

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.

Table and record variables get modified by reference, so you need to create a copy of table/record using assign option, then use this copy as dictionary value.

 

If assign record has the same effect, then assign action has bugs, it makes no sense for assigning record to new record having the same reference, they are the exact variables then.


Table and record variables get modified by reference, so you need to create a copy of table/record using assign option, then use this copy as dictionary value.

 

If assign record has the same effect, then assign action has bugs, it makes no sense for assigning record to new record having the same reference, they are the exact variables then.

That makes sense to me.

I did double check with assigning the record to a new variable, and it still behaved the same acting as a reference.

It seems like I’ll need to figure out some different way to handle my logic if this wont work.


Reply