Python Forum
Convert List of Dictionary to dictionary of dictionary list in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert List of Dictionary to dictionary of dictionary list in python
#1
Hi ALl ,

Need your help in python code for the following output required. thanks in advance.

Source file:


[ { "Env" :"dit",
"id": 1,
"appId": "AP11232",
"health": true
},
{ "Env" :"dit",
"id": 2,
"appId": "AP11232",
"health": false
}
{
"Env" :"int",
"id": 1,
"appId": "AP11232",
"health": true
},
{
"Env" :"int",
"id": 2,
"appId": "AP11232",
"health": true
},
{
"Env" :"int",
"id": 3,
"appId": "AP11232",
"health": true
},
{
"Env" :"int",
"id": 4,
"appId": "AP11232",
"health": true
}
]

Output Required:


{
"dit": [
{
"id": 1,
"appId": "AP11232",
"health": true
},
{
"id": 2,
"appId": "AP11232",
"health": false
}
],
"int":[
{
"id": 1,
"appId": "AP11232",
"health": true
},
{
"id": 2,
"appId": "AP11232",
"health": true
},
{
"id": 3,
"appId": "AP11232",
"health": true
},
{
"id": 4,
"appId": "AP11232",
"health": true
}]
}
Reply


Messages In This Thread
Convert List of Dictionary to dictionary of dictionary list in python - by kk230689 - Apr-26-2019, 02:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Using Lists as Dictionary Values bfallert 4 106 15 minutes ago
Last Post: bfallert
  How to parse and group hierarchical list items from an unindented string in Python? ann23fr 0 182 Mar-27-2024, 01:16 PM
Last Post: ann23fr
  Matching Data - Help - Dictionary manuel174102 1 397 Feb-02-2024, 04:47 PM
Last Post: deanhystad
  Dictionary in a list bashage 2 544 Dec-27-2023, 04:04 PM
Last Post: deanhystad
  filtering a list of dictionary as per given criteria jss 5 668 Dec-23-2023, 08:47 AM
Last Post: Gribouillis
  need to compare 2 values in a nested dictionary jss 2 855 Nov-30-2023, 03:17 PM
Last Post: Pedroski55
  Sort a list of dictionaries by the only dictionary key Calab 1 488 Oct-27-2023, 03:03 PM
Last Post: buran
  python dictionary is that a bug ? rmangla 2 589 Sep-27-2023, 05:52 AM
Last Post: DPaul
  No matter what I do I get back "List indices must be integers or slices, not list" Radical 4 1,161 Sep-24-2023, 05:03 AM
Last Post: deanhystad
  Code understanding: Need help in understanding dictionary code jt123 0 468 Jul-09-2023, 01:13 PM
Last Post: jt123

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020