Hi - I have two similar but different csv data files:
File A
Field 0: Part Number
Field 1: Description
Field 2: Price
File B
Field 0: Part Number
Field 1: Description
Field 2: New Part Number
Field 3: Price
I read File A's data in using this code. I'm sure it can be done in other or more efficient ways but this works well for me:
#################################
# reading data in from File A
while ( <> ) {
$csv->parse($_);
push(@AoA, [$csv->fields]);
}
# load up the hash
for my $i ( 0 .. $#AoA ) {
$HoA{$AoA[$i][5]} = $AoA[$i];
} # end looping over rows
#################################
I then read File B's data in a similar way:
#################################
# reading data in from File B
while ( <TEXTFILE> ) {
$csv->parse($_);
push(@H_USES, [$csv->fields]);
}
close(TEXTFILE);
print "Done Loading USES Data\n";
# load up the hash
for my $i ( 0 .. $#H_USES ) {
$H_USES{$H_USES[$i][5]} = $H_USES[$i];
} # end looping over rows
#################################
Now I want to append data from File B onto the the hash I made from File A. If the file structures were identical I could simply do this:
##################################
# Add on File B's data
for my $i ( 0 .. $#H_USES ) {
$HoA{$H_USES[$i][5]} = $H_USES[$i];
} # end looping over rows
##################################
But of course they are not identical. I want to simply ignore or skip over Field 2 from File B. I'm having trouble cooking up how to do this, so I thought I'd ask the gurus here. Any ideas would be appreciated.