def find_block(csv, name):
    """For an Illumina SampleSheet.csv, return a tuple of the index of the
    line containing the header specified by name, and the index of the
    line just past the end of the data block. `range(*r)` will index
    all lines for the block, starting at the header line.
    """
    start = None
    end = None

    def blockend(f):
        maxfieldlen = max([0] + [len(x) for x in f])
        if len(f) > 0 and len(f[0]) > 0 and f[0][0] == "[" and f[0][-1] == "]":
            return True
        return 0 == maxfieldlen

    for i, fields in enumerate(csv):
        if len(fields) > 0 and fields[0] == name:
            start = i
        elif start is not None and blockend(fields):
            return start, i
    if start is not None:
        end = len(csv)
    return start, end