I have a large file of names data with the source data in English and the corresponding equivalent in a different script. The two are delimited by an equal to sign.
=It so happens that because of data entry mismatch occurs between the number of names in English data does not find an equivalent in the corresponding scripts. Thus 3 names in English map to 2 names in the target language and so on. I am giving a pseudo-example below.
Peter=Pierre John Baker=JeanBoulanger Mary Brown Smith=Marie Brown
With the help of the internet the I wrote a perl script which can separate out the matched from the not-matched and in the non-matched file indicate if possible provide the degree of deviation:
Matched file JPeter=Pierre Notmatched file John Baker=JeanBoulanger(1) Mary Brown Smith=Marie Brown(1)
Here it is below:
#!/usr/bin/perl use strict; use warnings; open(FILE, "<try"); while (my $line = <$try>) { my ($left, $right) = split /=/, $line; my @left_array = split / /, $left; my @right_array = split / /, $right: my $left_count = scalar @left_array; my $right_count = scalar @right array; if ($left_count == $right_count) { print $matched_file $line; } else { chomp $line; my $diff = abs (left_count - $right_count) print $unmatched_file $line, "($diff) \n"; } }
Since I am a newbie to Perl, I guess I have goofed up and I consistently get dumps.
Please helpIn reply to Identifying unmatched data in a database by ardibehest
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |