def join_rows(rows, sep='\n'):
    """Given a list of rows (a list of lists) this function returns a
    flattened list where each the individual columns of all rows are joined
    together using the line separator.

    """
    output = []
    for row in rows:
        if len(output) <= len(row):
            for i in range(len(row) - len(output)):
                output.extend([[]])
        for i, field in enumerate(row):
            field_text = field.strip()
            if field_text:
                output[i].append(field_text)
    return list(map(lambda lines: sep.join(lines), output))
