[% USE CSV -%]
[% CSV.dump([ 'VLAN' 'Device' 'Description' 'Ports' 'Model' 'OS' 'Vendor' ]) %]

[% FOREACH row IN results %]
  [% mylist = [] %]
  [% device = row.dns || row.ip %]
  [% FOREACH col IN [ row.vlans.vlan device row.vlans.description row.pcount row.model row.os row.vendor ] %]
    [% mylist.push(col) %]
  [% END %]
  [% CSV.dump(mylist) %]

[% END %]
