python - Appending column from one tsv file to another (unix) -


i have 2 tsv files, each headers , columns. file has headers: sampleid & rawreads, fileb has headers: sampleid & readspost. want append readspost filea data lines correct sampleid.

my original plan in python using dictionaries keys being sampleids. however, there must easier way in bash!

any great!

use join , full outer join (or other type of join):

>cat test.txt test2.txt sampleid  rawreads 1         18 2         15 5         21 7         7 sampleid     readspost 1            yes 3            no 4            yes 5            yes  > join -a1 -a2 test.txt test2.txt sampleid rawreads readspost 1 18 yes 2 15 3 no 4 yes 5 21 yes 7 7 

note: -a argument prints lines file aren't joined. full outer join, print lines both files, exemplified.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -