note
nabiana
<p> Hi, just joined minutes ago. I am trying join tab-delimited files into a single file/table </p> Example, say I have these 4 files/tables: <p>
ID value (table1)</p>
<p>Aa 22</p>
<p>Bb 28</p>
<p>Cc 32</p>
<p>Dd 50</p>
ID value (table2)
<p>Aa 34</p>
<p>Cc 112</p>
<p>Dd 77</p>
<p>Ee 89</p>
<p>Kk 124</p>
ID value (table3)
<p>Bb 75</p>
<p>Cc 91</p>
<p>Dd 132</p>
ID value (table4)
<p>Aa 66</p>
<p>Cc 94</p>
<p>Ee 213</p>
<p>Gg 250</p>
<p> The output after joining should look like this:</P>
ID value1 value2 value3 value4
<p>Aa 22 34 0 66</p>
<p>Bb 28 0 75 0</p>
<p>Cc 32 112 91 94</p>
<p>Dd 50 77 132 0</p>
<p>Ee 0 89 0 213</p>
<p>Gg 0 0 0 250</p>
<p>Kk 0 124 0 0</p>
<p> My best effort:
<code> #usr/bin/perl!
use strict;
#I opened all files (containg the tables) one by one; is #there a way I can open all files at once?
open(FILEH1, "<table1.txt");
while (my $file = <FILEH1>){
chomp $file;
my @file1 = split('\t', $file); #to pick IDs and #values => $file1[0] and $file1[1]
}
open(FILEH2, "<table2.txt");
#and continued to tables 3 and 4.
#And then I tried to collect the items which is where I got #stuck.</code>
932460
932476