DataPipeline/Utilities.py
def buildNestedStructure(data, labels1, labels2):
    """Rebuild a nested dictionary from a flat sructure according to labels"""
    newdata = {}
    for key in data:
        pri = labels1[key]
        sec = labels2[key]
        #print key, pri, sec
        if not newdata.has_key(pri):
            newdata[pri] = {}
            if len(data[key])==1:
                item = data[key][data[key].keys()[0]]
            else:
                item = data[key]
            newdata[pri][sec] = item
    return newdata
Rebuild a nested dictionary from a flat sructure according to labels
Rebuild a nested dictionary from a flat sructure according to labels
Rebuild a nested dictionary from a flat sructure according to labels
def buildNestedStructure(data, labels1, labels2):
    newdata = {}
    for key in data:
        pri = labels1[key]
        sec = labels2[key]
        if not newdata.has_key(pri):
            newdata[pri] = {}
            if len(data[key])==1:
                item = data[key][data[key].keys()[0]]
            else:
                item = data[key]
            newdata[pri][sec] = item
    return newdata
def buildNestedStructure ( data , labels1 , labels2 ) : newdata = { } for key in data : pri = labels1 [ key ] sec = labels2 [ key ] if not newdata . has_key ( pri ) : newdata [ pri ] = { } if len ( data [ key ] ) == 1 : item = data [ key ] [ data [ key ] . keys ( ) [ 0 ] ] else : item = data [ key ] newdata [ pri ] [ sec ] = item return newdata
Rebuild a nested dictionary from a flat sructure according to labels
Rebuild a nested dictionary from a flat sructure according to labels
"""Rebuild a nested dictionary from a flat sructure according to labels""" #print key, pri, sec
data
labels1
labels2