Return data from dbf file fn as a dict.

    fn: str
        The filename string.

    usecols: seqence
        The columns to use, 0-based.

    keystyle: str
        'ints' or 'names' accepted. Should be 'ints' (default) when this
        function is given to a ChannelPack as loadfunc. If 'names' is
        used, keys will be the field names from the dbf file.

def dbf_asdict(fn, usecols=None, keystyle='ints'):
    """Return data from dbf file fn as a dict.

    fn: str
        The filename string.

    usecols: seqence
        The columns to use, 0-based.

    keystyle: str
        'ints' or 'names' accepted. Should be 'ints' (default) when this
        function is given to a ChannelPack as loadfunc. If 'names' is
        used, keys will be the field names from the dbf file.

    """

    if keystyle not in ['ints', 'names']:
        raise ValueError('Unknown keyword: ' + str(keystyle))

    with open(fn, 'rb') as fo:
        rit = dbfreader(fo)
        names = rit.next()
        specs = rit.next()      # NOQA
        R = [tuple(r) for r in rit]

    def getkey(i):
        if keystyle == 'ints':
            return i
        else:
            return names[i]

    R = zip(*R)
    d = dict()
    for i in usecols or range(len(names)):
        # d[getkey(i)] = R['f' + str(i)]  # Default numpy fieldname
        d[getkey(i)] = np.array(R[i])
    return d