I have a dictionary like this:
Files:
{'key1': ['path1', 'path1', 'path2', 'path1', 'path2'],
'key2': ['f', 'f', 'f', 'f', 'f'],
'key_file': ['file1', 'file1', 'file2', 'file1', 'file2']}
I want to delete all the duplicate values und in 'key_file' and their other values in the other keys ('key1' and 'key2').
Desired dictionary:
Files:
{'key1': ['path1', 'path2'],
'key2': ['f', 'f'],
'key_file': ['file1', 'file2']}
I couldn't figure out a solution which preserved the order and deleted every duplicate item and their values in the other keys.
Thanks a lot.
EDIT:
'key2': ['f', 'f', 'f', 'f', 'f']
becomes
'key2': ['f', 'f'],
because there are two distinct files.
I don't want to delete every duplicate in every key. 'path1' is related to 'file1' and 'path2' is related to 'file2' as is the 'f' in key2 for both cases. Actually in reality there are several keys more, but this is my minimal example. That is my problem. I have found several solutions to delete every duplicate.
EDIT2:
Maybe I was a bit confusing.
Every key has the same length as they describe a filename (in key_file), the according path (in key1) and some other describing strings (in key2, etc). It can happen that the same file is stored in different locations (paths), but I know, that it is the same file if the filename is exactly the same.
Basically what I was looking for, is a function which detects the second value of key_file with the filename file1 as a duplicate of the first value file1 and deletes the second value from every key. The same for value number 4 (file1) and 5 (file2). The resulting dictionary would then look like the one I mentioned.
I hope this explains it better.