username, date_modified
2010-nhw-es-ea-285, 2012-10-10
aab.external.audit.-.bvr.verif.externes, 2012-02-22
aashee.aziz, 2012-01-27
abbas.rangwala, 2012-01-27
abbie.gardner, 2012-09-10
ab.border-frontiere, 2012-08-11
abdool.yasseen, 2012-01-31
abdullah.aboukarr, 2012-08-10
abdullahi.sheikh, 2012-02-28
(There is 544 lines)
####
fullname, branch
aaron.northway, CHIEF FINANCIAL OFFICER BRANCH
aashee.aziz, HEALTH PRODUCTS AND FOOD BRANCH
abbey.klugerman, HEALTHY ENVIRONMENTS AND CONSUMER SAFETY BRANCH
abby.hoffman, STRATEGIC POLICY BRANCH
abderrahim.boussanni, CHIEF FINANCIAL OFFICER BRANCH
abdiaziz.nur, HEALTHY ENVIRONMENTS AND CONSUMER SAFETY BRANCH
abdool.yassin, HEALTH PRODUCTS AND FOOD BRANCH
abdoulie.manjang, N/A
abdullah.hassen, HEALTH PRODUCTS AND FOOD BRANCH
abdullah.patel, REGIONS AND PROGRAMS BRANCH
(There is 12489 lines)
####
username, branch, date_modified
aashee.aziz, HEALTH PRODUCTS AND FOOD BRANCH, 2012-01-27
abdool.yasseen, HEALTH PRODUCTS AND FOOD BRANCH, 2012-01-31
####
Method #1
#!F:\Perl_program\perl\bin\perl -w #I am using Portable Strawberry PERL on Windows XP.
use strict;
use warnings;
use DBI;
my $datafolder = "F:/Perl_program";
my $dbh = DBI->connect(
"dbi:CSV:f_dir=$datafolder;f_ext=.csv;csv_eol=\n;"
);
$dbh->{'csv_tables'}->{"HCDir2.csv"} = {'col_names' => ["fullname", "branch"]};
$dbh->{'csv_tables'}->{"final2.csv"} = {'col_names' => ["username", "date_modified"]};
$dbh->do("
CREATE TABLE completed.csv
AS SELECT final.username,HCDir.branch,final.date_modified
FROM HCDir
INNER JOIN final
ON final.username = HCDir.fullname
");
####
Method #2
#!F:\Perl_program\perl\bin\perl -w #I am using Portable Strawberry PERL on Windows XP.
use strict;
use warnings;
use DBI;
open FINAL, "completed.csv" or die();
our %hash1;
our %hash2;
while () {
our ($username, $date_modified) = split;
$hash1{$username} = $date_modified;
}
while () {
our ($fullname, $branch) = split;
$hash2{$fullname} = $branch;
}
if (our $username = our $fullname){
print OUTFILE "$username $hash2{$fullname} $hash1{$username}\n";
}
close FINAL;
close HCDIR;
close OUTFILE;
####
Method #3
#!F:\Perl_program\perl\bin\perl -w #I am using Portable Strawberry PERL on Windows XP.
use strict;
use warnings;
open (HCDIR, "nbmd.csv") or die "$!";
our $line1;
our $line2;
our @lines1 = ();
our @lines2 = ();
foreach $line2(@lines2){
our @linearr2 = split (',', $line2);
our $fullname = $linearr2[0];
our $branch = $linearr2[1];
}
foreach $line1(@line1){
our @linearr1 = split (',', $line1);
our $username = $linearr1[0];
our $date_modified = $linearr1[1];
}
while (){
if ($username eq $fullname){
our $nbmd = join (',', "$username,$branch$,date_modified");
chomp $nbmd;
print NBMD ("$nbmd\n");
}
}
close (FINAL);
close (HCDIR);
close (NBMD);
####
Method #4
#!F:\Perl_program\perl\bin\perl -w #I am using Portable Strawberry PERL on Windows XP.
use strict;
use warnings;
our $file1 = "F:/Perl_program/final2.csv";
our $file2 = "F:/Perl_program/HCDir2.csv";
our $fileOut = "F:/Perl_program/completed.csv";
our %file1Map = ();
our %file2Map = ();
open (FILE1, "completed.csv") or die("Could not open $fileout file.");
foreach $fileout(){
(our $username2,our $dumour)=split('\n',$fileout);
our $existingValue = $File1Map{"$username"};
our $newValue = $File2Map{"$fullname"};
if (! defined $existingValue){
$existingValue = ",";
}
if (! defined $newValue){
$newValue = "\n";
}
print OUTFILE "" . $username2 . "," . $existingValue . "," . $newValue;
}
close (OUTFILE);