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

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.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  convert list to five columns dataframe in sequence tonycat 2 104 Sep-29-2020, 06:47 AM
Last Post: tonycat
  How to remove dict from a list? Denial 7 163 Sep-28-2020, 02:40 PM
Last Post: perfringo
  Appending to list of list in For loop nico_mnbl 2 101 Sep-25-2020, 04:09 PM
Last Post: nico_mnbl
  Split dict of lists into smaller dicts of lists. pcs3rd 3 223 Sep-19-2020, 09:12 AM
Last Post: ibreeden
  trouble with list array Milfredo 2 161 Sep-16-2020, 12:07 AM
Last Post: Milfredo
  Trouble with converting list , dict to int values! faryad13 7 309 Sep-04-2020, 06:25 AM
Last Post: faryad13
  How to make a list of values from a dictionary list? faryad13 2 139 Sep-03-2020, 03:45 PM
Last Post: faryad13
  Convert xml to dict and group data and sum totals kashcode 5 257 Aug-16-2020, 01:04 AM
Last Post: scidam
  convert array of numbers to byte array adetheheat 3 249 Aug-13-2020, 05:09 PM
Last Post: bowlofred
  Append list into list within a for loop rama27 2 285 Jul-21-2020, 04:49 AM
Last Post: deanhystad

Forum Jump:

Users browsing this thread: 1 Guest(s)