I have a list of dictionaries called dicts
. I am writing dicts
into a csv file using DictWriter. dicts
has duplicate keys like: Accepted Currencies (DASH)
and Accepted Currencies (Dash)
which I would like to merge those keys into a single key with uppercase i.e. I want to only keep Accepted Currencies (DASH)
as a key and keep the value of that removed key as well; in this case keep the value of Accepted Currencies (Dash)
. For instance, currently, my dicts contains the following:
dicts = [{'Accepted Currencies (DASH)': 'DASH'}, {'Accepted Currencies (Dash)': 'Dash'}]
But I want to have something like the following:
dicts = [{'Accepted Currencies (DASH)' : 'DASH'}, {'Accepted Currencies (DASH)': 'Dash'}]
Here is my code:
dicts = []
for j in range(1,39):
for i in range(1,10):
###Some code here to calculate super_dict
super_dict.update(social_urls)
super_dict.update(metadata)
super_dict.update(project_name)
super_dict.update(bc_dict)
super_dict.update(ind_dict)
super_dict.update(pos_dict)
super_dict.update(likes_dict)
super_dict.update(memprof_dict)
super_dict.update(video_link)
super_dict.update(details_dict)
dicts.append(super_dict)