Read data from a spread sheet. Return the data in a dict with
    column numbers as keys.

    sheet: xlrd.sheet.Sheet instance
        Ready for use.

    startstops: list
        Four StartStop objects defining the data to read. See
        :func:`~channelpack.pullxl.prepread`.

    usecols: str or seqence of ints or None
        The columns to use, 0-based. 0 is the spread sheet column
        "A". Can be given as a string also - 'C:E, H' for columns C, D,
        E and H.

    Values in the returned dict are numpy arrays. Types are set based on
    the types in the spread sheet.

def _sheet_asdict(sheet, startstops, usecols=None):
    """Read data from a spread sheet. Return the data in a dict with
    column numbers as keys.

    sheet: xlrd.sheet.Sheet instance
        Ready for use.

    startstops: list
        Four StartStop objects defining the data to read. See
        :func:`~channelpack.pullxl.prepread`.

    usecols: str or seqence of ints or None
        The columns to use, 0-based. 0 is the spread sheet column
        "A". Can be given as a string also - 'C:E, H' for columns C, D,
        E and H.

    Values in the returned dict are numpy arrays. Types are set based on
    the types in the spread sheet.
    """

    _, _, start, stop = startstops
    usecols = _sanitize_usecols(usecols)

    if usecols is not None:
        iswithin = start.col <= min(usecols) and stop.col > max(usecols)
        mess = 'Column in usecols outside defined data range, got '
        assert iswithin, mess + str(usecols)
    else:                       # usecols is None.
        usecols = tuple(range(start.col, stop.col))

    # cols = usecols or range(start.col, stop.col)
    D = dict()

    for c in usecols:
        cells = sheet.col(c, start_rowx=start.row, end_rowx=stop.row)
        types = set([cell.ctype for cell in cells])

        # Replace empty values with nan if appropriate:
        if (not types - NANABLE) and xlrd.XL_CELL_NUMBER in types:
            D[c] = np.array([np.nan if cell.value == '' else cell.value
                             for cell in cells])
        elif xlrd.XL_CELL_DATE in types:
            dm = sheet.book.datemode
            vals = []
            for cell in cells:
                if cell.ctype == xlrd.XL_CELL_DATE:
                    dtuple = xlrd.xldate_as_tuple(cell.value, dm)
                    vals.append(datetime.datetime(*dtuple))
                elif cell.ctype in NONABLES:
                    vals.append(None)
                else:
                    vals.append(cell.value)
            D[c] = np.array(vals)
        else:
            vals = [None if cell.ctype in NONABLES else cell.value
                    for cell in cells]
            D[c] = np.array(vals)

    return D