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
Hi All,

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

[{'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}]
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

Life of Brian: Conjugate the verb, "to go" !

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  I created a function that generate a list but the list is empty in a new .py file mrhopeedu 2 91 Oct-12-2019, 08:02 PM
Last Post: mrhopeedu
  size of set vs size of dict zweb 0 119 Oct-11-2019, 01:32 AM
Last Post: zweb
  Merge two dict with same key RavCOder 3 132 Oct-10-2019, 03:56 PM
Last Post: RavCOder
  [split] capitalize dict keys for display in string newbieAuggie2019 3 162 Oct-10-2019, 10:50 AM
Last Post: perfringo
  How to read a text file into a list or an array musouka 2 191 Oct-07-2019, 01:54 PM
Last Post: musouka
  Creating a list from a comprehension using a list rm197 6 111 Sep-30-2019, 07:02 PM
Last Post: rm197
  Converting List into list of tuples ARV 4 268 Sep-28-2019, 04:58 AM
Last Post: perfringo
  Most efficient way of reshaping a list-array structure midarq 2 109 Sep-25-2019, 09:32 AM
Last Post: midarq
  My dict is not good blackknite 9 308 Sep-23-2019, 10:44 AM
Last Post: blackknite
  dict problem with if Adem 3 161 Sep-22-2019, 06:38 AM
Last Post: ndc85430

Forum Jump:

Users browsing this thread: 1 Guest(s)