def dictify(values, colnames):
    """
    Convert a list of values into a dictionary based upon given column names.

    If the column name starts with an '@', the value is assumed to be a comma
    separated list.

    If the name starts with a '#', the value is assumed to be an int.

    If the name starts with '@#', the value is assumed to  a comma separated
    list of ints.

    """
    d = {}
    for i in xrange(len(colnames)):
        key = colnames[i]
        split = False
        num = False

        if key[0] == '@':
            key = key[1:]
            split = True
        if key[0] == '#':
            key = key[1:]
            num = True

        if i < len(values):
            if num and split:
                val = [int(x) for x in values[i].rstrip(',').split(',')]
            elif num:
                val = int(values[i])
            elif split:
                val = values[i].rstrip(',').split(',')
            else:
                val = values[i]

            d[key] = val

        else:
            d[key] = None

    return d
dataset/ETHPy150Open ngsutils/ngsutils/ngsutils/support/ngs_utils.py/dictify/original