in reply to parsing CSV
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 --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: parsing CSV
by younggrasshopper13 (Novice) on Oct 07, 2016 at 03:15 UTC | |
by GrandFather (Saint) on Oct 07, 2016 at 03:34 UTC | |
by younggrasshopper13 (Novice) on Oct 07, 2016 at 05:01 UTC | |
by GrandFather (Saint) on Oct 07, 2016 at 06:23 UTC | |
by younggrasshopper13 (Novice) on Oct 07, 2016 at 07:03 UTC | |
| |
by younggrasshopper13 (Novice) on Oct 08, 2016 at 02:15 UTC | |
by AnomalousMonk (Archbishop) on Oct 08, 2016 at 03:13 UTC | |
by younggrasshopper13 (Novice) on Oct 08, 2016 at 17:42 UTC | |
|