sidpy/base/dict_utils.py
def nest_dict(flat_dict, separator='-'):
    """
    Generates a nested dictionary from a flattened dictionary

    Parameters
    ----------
    flat_dict : dict
        Dictionary whose keys are flattened to a single string with a separator
    separator : str, optional. Default = '-'
        Separator used to delimit the levels in the keys

    Returns
    -------
    nested_dict : dict
        Nested dictionary

    Notes
    -----
    flat_dict should look like {'A|B|C': V1, 'A|B|D': V2, ...}
    """
    nested_dict = dict()
    conflict_items = dict()
    for key, val in flat_dict.items():
        this_dict = nested_dict_from_flattened_key({key: val},
                                                   separator=separator)
        try:
            # merge the nested dictionaries:
            nested_dict = merge_dicts(nested_dict, this_dict)
        except ValueError as exp:
            warn(exp)
            conflict_items.update({key: val})
    if len(conflict_items) > 0:
        return nested_dict, conflict_items
    return nested_dict

    Generates a nested dictionary from a flattened dictionary

    Parameters
    ----------
    flat_dict : dict
        Dictionary whose keys are flattened to a single string with a separator
    separator : str, optional. Default = '-'
        Separator used to delimit the levels in the keys

    Returns
    -------
    nested_dict : dict
        Nested dictionary

    Notes
    -----
    flat_dict should look like {'A|B|C': V1, 'A|B|D': V2, ...}
    
Generates a nested dictionary from a flattened dictionary
Parameters

flat_dict : dict
Dictionary whose keys are flattened to a single string with a separator
separator : str, optional. Default = '-'
Separator used to delimit the levels in the keys

Returns

nested_dict : dict
Nested dictionary

Notes


Generates a nested dictionary from a flattened dictionary Parameters flat_dict : dict Dictionary whose keys are flattened to a single string with a separator separator : str optional . Default = ' - ' Separator used to delimit the levels in the keys Returns nested_dict : dict Nested dictionary Notes
def nest_dict(flat_dict, separator='-'):
    nested_dict = dict()
    conflict_items = dict()
    for key, val in flat_dict.items():
        this_dict = nested_dict_from_flattened_key({key: val},
                                                   separator=separator)
        try:
            nested_dict = merge_dicts(nested_dict, this_dict)
        except ValueError as exp:
            warn(exp)
            conflict_items.update({key: val})
    if len(conflict_items) > 0:
        return nested_dict, conflict_items
    return nested_dict
def nest_dict ( flat_dict , separator = '-' ) : nested_dict = dict ( ) conflict_items = dict ( ) for key , val in flat_dict . items ( ) : this_dict = nested_dict_from_flattened_key ( { key : val } , separator = separator ) try : nested_dict = merge_dicts ( nested_dict , this_dict ) except ValueError as exp : warn ( exp ) conflict_items . update ( { key : val } ) if len ( conflict_items ) > 0 : return nested_dict , conflict_items return nested_dict
Generates a nested dictionary from a flattened dictionary
Parameters
Generates a nested dictionary from a flattened dictionary Parameters
"""
    Generates a nested dictionary from a flattened dictionary

    Parameters
    ----------
    flat_dict : dict
        Dictionary whose keys are flattened to a single string with a separator
    separator : str, optional. Default = '-'
        Separator used to delimit the levels in the keys

    Returns
    -------
    nested_dict : dict
        Nested dictionary

    Notes
    -----
    flat_dict should look like {'A|B|C': V1, 'A|B|D': V2, ...}
    """ # merge the nested dictionaries:
flat_dict
separator