Insert column to a CSV file in Perl using Text::CSV_XS module

Viewed 3856

How can I add column to a CSV file using the Text::CSV_XS module?

The print routine in the module only writes the array as a row. If I have an array, how can I write it to the file as a column? I already wrote the code below

open my $outFH, ">", $outFile or die "$outFile: $!";
$outFilecsv = Text::CSV_XS->new ({ binary => 1, eol => $/ });              
@column = read_column($inFile, $i);
$outFilecsv->print($outFH, \@column)or $outFilecsv->error_diag;

where read_column method reads returns a specified column from another csv file.

1 Answers
Related