You say you want solutions in Python, MySQL or MongoDB. But you’ve tagged the question with “perl”. So here’s a Perl solution.
#!/usr/bin/perl
use strict;
use warnings;
my %file1 = get_file1();
open my $fh2, '<', 'File2' or die "File 2: $!\n";
chomp(my $header = <$fh2>);
print "$header\tcol_F\n";
while (<$fh2>) {
chomp;
my $colA = (split ' ')[0];
print "$_\t$file1{$colA}\n";
}
sub get_file1 {
my %hash;
open my $fh1, '<', 'File1' or die "File 1: $!\n";
<$fh1>; # skip headers
while (<$fh1>) {
chomp;
my ($key, $val) = split ' ';
$hash{$key} = $val;
}
return %hash;
}
4
solved How to inner join two tables?