WarningLibraryFromCsv operation failed. An item with the same key has already been added

Hi guys!
I’m trying to assign a rating from a warning library to my model’s warning.
When I connect the CSV file to “WarningLibraryFromCSV” node, it gives me:

“Warning: WarningLibrary.WarningLibraryFromCsv operation failed.
An item with the same key has already been added.”

In the library there are early 810 Warning, any suggest to find and delete the key already been added?

Thanks in advance

00_AssignWarningRating_WIP.dyn (6.2 KB)

WarningLibrary…txt (82.0 KB)

Using the CSV nodes would likely be easier than using the read text, but here it goes…

String.Split, with a new line character (enter on your keyboard in a string node, or “/n” in a code block) as the split character to break the CSV down by line.

Then a String.Split with a , as the split character to break each line into a [key,value] list.

Then a List.FirstItem with longest lacing to get the ‘key’ from the pair sequence.

Then a List.GroupByKey node to to group the pair values by the keys.

Lastly a List.Count node with longest lacing to ID which key exists twice.

I would edit the offending entry in the CSV directly rather than computationally sanitize it.

1 Like

Thank you Jacob! I fixed the CSV directly

1 Like