The HoH worked, Thank you. Since the HoH is not sorted so how can we compare the key of hashes with the node latitude and longitude and update the names. For e.g. what should be the condition in the if statement?
my $inputfile = 'test_data.csv'; my $csv = Text::CSV->new ({binary => 1,auto_diag => 1,sep_char =>';'} +); open(my $data, '<:encoding(utf8)', $inputfile) or die "Could not open +'$inputfile' $!\n"; my $header = $csv->getline($data); $csv->column_names($header); my %HoH; while (my $row = $csv->getline_hr($data)) { my $key = "$row->{latitude}.$row->{longitude}"; # Compare next if exists $HoH{$key} && $row->{id} >= $HoH{$key}->{id}; # Set (or overwrite) $HoH{$key} = {name => $row->{name},id => $row->{id}}; } foreach my $key1 (keys %HoH) { print "'$key1'\n"; foreach my $key2 (keys %{$HoH{$key1}}) { print $key2=$HoH{$key1}{$key2},"\n"; } } my $myhash = \%HoH; my $dom = 'XML::LibXML'->load_xml(location => 'test.osm'); for my $node ($dom->findnodes('/osm/node')) { my $tag = $node->findnodes('tag[@k="name"]')->[0]; print $tag,"\n"; if () { } }
In reply to Re^4: Update XML Values using two primary keys
by pratikpooja
in thread Update XML Values using two primary keys
by pratikpooja
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |