def add_row_filter(source, args, index):
    """Add the hxlselect filter to the end of the pipeline."""
    queries = []
    for subindex in range(1, 6):
        query = args.get('select-query%02d-%02d' % (index, subindex))
        if query:
            queries.append(query)
    reverse = args.get('select-reverse%02d' % index) == 'on'
    if reverse:
        return source.without_rows(queries)
    else:
        return source.with_rows(queries)
