You don't show what the page data may look like so I assume that you know how to wrangle it into raw CSV. Given that, you can match the data up by stuffing it into a hash:
use strict; use warnings; use Text::CSV; my $page1 = <<PG1CSV; 1,23 2,10 3,23 PG1CSV my $page2 = <<PG2CSV; 1,younggrasshopper13 2,GrandFather 4,Mr. Unknown PG2CSV my $csv = Text::CSV->new(); my %idData; open my $pg1In, '<', \$page1; while (my $row = $csv->getline($pg1In)) { $idData{$row->[0]}{size} = $row->[1]; $idData{$row->[0]}{name} = '-- missing --'; } close $pg1In; open my $pg2In, '<', \$page2; while (my $row = $csv->getline($pg2In)) { $idData{$row->[0]}{name} = $row->[1]; $idData{$row->[0]}{size} //= '-- missing --'; } close $pg2In; for my $id (sort keys %idData) { print "$id: $idData{$id}{name} size $idData{$id}{size}\n"; }
Prints:
1: younggrasshopper13 size 23 2: GrandFather size 10 3: -- missing -- size 23 4: Mr. Unknown size -- missing --
In reply to Re: parsing CSV
by GrandFather
in thread parsing CSV
by younggrasshopper13
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |