Skip to content

Instantly share code, notes, and snippets.

@spectras
Created November 9, 2015 03:26
Show Gist options
  • Save spectras/0f50994c7086fb139567 to your computer and use it in GitHub Desktop.
Save spectras/0f50994c7086fb139567 to your computer and use it in GitHub Desktop.
# http://stackoverflow.com/questions/33601864
products = {
'Cat1': {
'Prod1': {
'comment': 'ABC',
'indicator': 'Flat',
'pricelow': '10',
'priceaverage': '20',
'pricehigh': '30'},
'Prod2:': {
'comment': 'ABC',
'indicator': 'Flat',
'pricelow': '20',
'priceaverage': '30',
'pricehigh': '40'},
'Prod3': {
'comment': 'ABC',
'indicator': 'Flat',
'pricelow': '50',
'priceaverage': '60',
'pricehigh': '70'}},
'Cat2': {
'Prod4': {
'comment': 'ABC',
'indicator': 'Flat',
'pricelow': '10',
'priceaverage': '20',
'pricehigh': '30'}}
}
productlist = []
for item in products:
for subitem in products[item]:
products[item][subitem]['name'] = subitem
productlist.append(products[item][subitem])
from pprint import pprint
pprint(productlist)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment