in reply to Re: How to swap columns in a csv file ?
in thread How to swap columns in a csv file ?
If you're ok with dealing with header indexes instead of header names, the above the be reduced to a single command:
csv in => \*ARGV, out => \*STDOUT, after_parse => sub { $_[1]->@* = $_[1]->@[ 1, 0, 3, 2 ] };
The whole thing as a one-liner:
perl -MText::CSV_XS=csv -e'csv in => \*ARGV, out => \*STDOUT, after_pa +rse => sub { $_[1]->@* = $_[1]->@[1,0,3,2] }' a.csv
|
---|