1[% USE CSV -%] 2[% CSV.dump([ 'Left Device' 'Port' 'Duplex' 'Right Device' 'Port' 'Duplex' ]) %] 3 4[% FOREACH row IN results %] 5 [% mylist = [] %] 6 [% device_left = row.left_dns || row.left_ip %] 7 [% device_right = row.right_dns || row.right_ip %] 8 [% FOREACH col IN [ device_left row.left_port row.left_duplex.ucfirst device_right row.right_port row.right_duplex.ucfirst ] %] 9 [% mylist.push(col) %] 10 [% END %] 11 [% CSV.dump(mylist) %] 12 13[% END %] 14