[% USE CSV -%]
[% CSV.dump([ 'Name' 'Port' 'Description' 'VLAN' ]) %]

[% FOREACH row IN results %]
  [% mylist = [] %]
  [% myport = "$row.ip [ $row.port ] (" _ (row.device.dns || row.device.name) _ ")" IF (row.device.dns || row.device.name) %]
  [% FOREACH col IN [ row.name myport row.descr row.port_vlans.vlan ] %]
    [% mylist.push(col) %]
  [% END %]
  [% CSV.dump(mylist) %]

[% END %]
