in reply to How to go about this?
Here's some untested skeleton code.
my @out; open my $main_fh, '<', 'main.csv' or die "Can't read main.csv: $!"; while (<$main_fh>) { chomp; push @out, [ $_ ]; } foreach my $file ( glob '200*.csv' ) { # you'll want to store this filename for your header open my $fh, '<', $file or die "Can't read '$file': $!"; /^(\d+),(\d+)$/ && push @{ $out[$1] }, $2 for <$fh>; } open my $out_fh, '>', 'out.csv' or die "Can't write 'out.csv': $!"; print {$out_fh} $header_line_here; print {$out_fh} join( q{,}, @{$_} ), "\n" for grep defined, @out;
Some notes:
I haven't tested it, but hopefully it gives you some ideas.
|
|---|