def build_dict(seq, key):
    """
    Turn an unnamed list of dicts into a nammed list of dicts
    Taken from stackoverflow
    https://stackoverflow.com/questions/4391697/find-the-index-of-a-dict-within-a-list-by-matching-the-dicts-value
    """
    return dict((d[key], dict(d, index=index)) for (index, d) in enumerate(seq))