I have two lists (these will be hundreds of records long) but here are samples:
list1 = [
{'VENDOR': 'VENDOR1', 'VLAN': '500', 'OUI': []},
{'VENDOR': 'VENDOR2', 'VLAN': '600', 'OUI': []},
{'VENDOR': 'VENDOR3', 'VLAN': '700', 'OUI': []},
]
list2 = [
{'VLAN': '500', 'OUI': '0001FC'},
{'VLAN': '600', 'OUI': '00D024'},
{'VLAN': '500', 'OUI': '00D024'},
{'VLAN': '700', 'OUI': '00D024'},
{'VLAN': '700', 'OUI': '023456'},
]
I want to take out every OUI from list2 where the VLAN matches between the two lists, then add it to the value for the OUI key in list1. (I imagine this may require a 3rd dict to hold everything).
The end result would be something like:
list3 = [
{'VENDOR': 'VENDOR1', 'VLAN': '500', 'OUI': ["0001FC", "00D024"]},
{'VENDOR': 'VENDOR2', 'VLAN': '600', 'OUI': ["00D024"]},
{'VENDOR': 'VENDOR3', 'VLAN': '700', 'OUI': ["00D024", "023456"]}
]
I'm not even sure where to start with this one, so any help is appreciated.