import csv


def parse_stream(stream, field=1, delim="\t"):
    """
    Parses a stream for a column.
    """
    # One based coordinate system.
    colidx = field - 1

    # Sanity check.
    assert colidx >= 0

    # Remove comments
    stream = filter(lambda x: not x.startswith('#'), stream)

    # Remove empty lines
    stream = filter(lambda x: x.strip(), stream)

    # Create a reader.
    reader = csv.reader(stream, delimiter=delim)

    # Keep only rows that have data for the column
    reader = filter(lambda row: len(row) >= colidx, reader)

    return [row[colidx] for row in reader]