convert list of dict to dict of array of list with pop up - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: convert list of dict to dict of array of list with pop up (/thread-21084.html) |
convert list of dict to dict of array of list with pop up - kk230689 - Sep-13-2019 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}] } RE: convert list of dict to dict of array of list with pop up - perfringo - Sep-13-2019 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. |