Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 convert list of dict to dict of array of list with pop up
#1
Hi All,

Need help to convert the input dictionary to o/p below format

input:
[{'type': 'cummulative', 'environment': None, 'domain': 'ARRAW', 'total_hits': 7, 'success': 1, 'failure': 6},
 {'type': 'cummulative', 'environment': None, 'domain': 'WQAT', 'total_hits': 33, 'success': 26, 'failure': 7}, 
 {'type': 'environment', 'environment': 'ACP', 'domain': 'WQAT', 'total_hits': 11, 'success': 11, 'failure': 0}, 
 {'type': 'environment', 'environment': 'DIT', 'domain': 'ARRAW', 'total_hits': 7, 'success': 1, 'failure': 6}, 
 {'type': 'environment', 'environment': 'DIT', 'domain': 'WQAT', 'total_hits': 11, 'success': 4, 'failure': 7}, 
 {'type': 'environment', 'environment': 'INT', 'domain': 'WQAT', 'total_hits': 11, 'success': 11, 'failure': 0}]
required O/P:
 {	WQAT:[{cummulative:[{'environment': None, 'domain': 'WQAT', 'total_hits': 33, 'success':26, 'failure': 7}],
	     environment: [{'environment':'ACP', 'domain': 'WQAT', 'total_hits': 11, 'success': 11, 'failure': 0},
						{'environment': 'DIT', 'domain': 'WQAT', 'total_hits': 11, 'success': 4, 'failure': 7}, 
					    {'environment': 'INT', 'domain': 'WQAT', 'total_hits': 11, 'success': 11, 'failure': 0}]
  ARRAW: [{cummulative:[{'environment': None, 'domain': 'ARRAW', 'total_hits': 7, 'success': 1, 'failure': 6}],
	     environment: [ {'environment': 'DIT', 'domain': 'ARRAW', 'total_hits': 7, 'success': 1, 'failure': 6}]
}
Quote
#2
First of all - what have you tried?

Second - is this output you actually want? Can you describe in spoken language based on what the new structure is built-up.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Randomly assign values in List 1 to a value in List 2 Seneca260 6 351 Dec-12-2019, 10:42 AM
Last Post: perfringo
  extract first and last 5 elements from given list and generate a new list. Raj_Kumar 1 90 Dec-07-2019, 05:03 PM
Last Post: ichabod801
  item = index position - list of list RavCOder 9 158 Dec-02-2019, 05:24 PM
Last Post: ThomasL
  Phyton code to load a comma separated csv file in to a dict and then in to a dB mrsenorchuck 2 196 Nov-29-2019, 10:59 AM
Last Post: mrsenorchuck
  updating certain values in dict. with relation to their keys malevy 17 258 Nov-27-2019, 02:37 PM
Last Post: buran
  Python list - group by dict key karthidec 2 133 Nov-25-2019, 06:58 AM
Last Post: buran
  List Comprehension - Creating a list of the length of an item help paul41 2 167 Nov-18-2019, 10:21 AM
Last Post: perfringo
  {} from dict suppressing Adem 2 118 Nov-15-2019, 09:28 PM
Last Post: micseydel
  Writing list as a file, then reading that file as a list Zoastria_Balnala 3 179 Oct-17-2019, 07:54 PM
Last Post: Zoastria_Balnala
  I created a function that generate a list but the list is empty in a new .py file mrhopeedu 2 148 Oct-12-2019, 08:02 PM
Last Post: mrhopeedu

Forum Jump:


Users browsing this thread: 1 Guest(s)