{# white space at end of each inner for loop line is important! #} {% for h in header %}{{ h }}{% if not loop.last %}{{ sep }}{% endif %}{% endfor %} {% for row in csvdata %} {% for col in row %}{{ col }}{% if not loop.last %}{{ sep }}{% endif %}{% endfor %} {% endfor %}