Read a CSV into Pillar

    :param str path: Absolute path to a CSV file.
    :param str idkey: (Optional) The column name of minion IDs.
    :param str namespace: (Optional) A pillar key to namespace the values under.
    :param list fieldnames: (Optional) if the first row of the CSV is not
        column names they may be specified here instead.

def ext_pillar(
        mid,
        pillar,
        path,
        idkey='id',
        namespace=None,
        fieldnames=None,
        restkey=None,
        restval=None,
        dialect='excel'):
    '''
    Read a CSV into Pillar

    :param str path: Absolute path to a CSV file.
    :param str idkey: (Optional) The column name of minion IDs.
    :param str namespace: (Optional) A pillar key to namespace the values under.
    :param list fieldnames: (Optional) if the first row of the CSV is not
        column names they may be specified here instead.
    '''
    with salt.utils.files.fopen(path, 'rb') as f:
        sheet = csv.DictReader(f, fieldnames,
                restkey=restkey, restval=restval, dialect=dialect)

        for row in sheet:
            if row[idkey] == mid:
                if namespace:
                    return {namespace: row}
                else:
                    return row

    return {}