I am trying convert a dictionary to simple comma separated string with duplicate keys removed.
here is my dictionary
"Message": [
{
"table_name": "sec_sp",
"column_name": "field_1"
},
{
"table_name": "sec_sp",
"column_name": "field_2"
},
{
"table_name": "sec_si",
"column_name": "field_3"
},
{
"table_name": "sec_si",
"column_name": "field_4"
},
{
"table_name": "sec_sp",
"column_name": "field_5"
},
{
"table_name": "sec_sc",
"column_name": "field_6"
},
{
"table_name": "sec_sc",
"column_name": "field_7"
}
]
I wanted to convert it to below strings.
sp_list = "field_1,field_2,field_5"
si_list = "field_3,field_4"
sc_list = "field_6,field_7"
I tried separating out to keys and values using below code however not able to remove dupes.
for key, value in Message.items():
New contributor
Sachin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.