I want to merge two CSV files that I have read into python using the following code,
a = csv.DictReader(csv1)
b = csv.DictReader(csv2)
aMap = {}
bMap = {}
for row in a:
aMap[row['id']] = row
for row in b:
bMap[row['id']] = row
Now I should have two dictionaries whose keys are the 'id' field from the two CSVs. What I want to do is take everything from the aMap and add the values to the corresponding key values to bMap. For example in aMap, a key in the dictionary looks like this,
'123456' : {'name': 'SomeName', 'type': 'someType'}
And what I have in bMap is
'123456' : {'location' : 'someLocation'}
And what I want is,
'123456' : {'location' : 'someLocation', 'name' : 'SomeName', 'type' : 'someType'}
Is there a specific function for this or do I have to create a new dictionary? Something similar to update() but just appending values instead of updating.