joinfiles.pl

Description

JoinFiles.pl Perl script is used for joining two files together based on one or two ID fields (columns) in the files.

Usage

Command is:

   joinfiles.pl

Program requires 6 command line arguments which are is this order:

   file1_field_1
   file1_field_2
   file1 name
   file2_field_1
   file2_field_2
   file2 name

Example of joining files file1.txt and file2.txt using columns 1 and 2 from file file1.txt and columns 1 and 2 from file file2.txt:

   joinfiles.pl 1 2 file1.txt 1 2 file2.txt

By default program outputs joined file to screen and redirecting output to new file can be done like this:

   joinfiles.pl 1 2 file1.txt 1 2 file2.txt > newfile.txt

All lines in file 2 that do not have a pair in file 1 will be ignored!! Also files must be in Unix format, use dos2unix command converting files!!

Only first match from file2.txt is printed to new file!!

Another example of joining files. We have pedigree (+ genotypes) and phenotype files:

And now let's join files and redirect output to file newfile.txt:

   joinfiles.pl 1 2 pedigree.dat 1 2 phen.dat > newfile.txt

One column join

Program can be also used for combining files only using one column from each file like this:

   joinfiles.pl 1 1 file1.txt 1 1 file2.txt

Authors

Tero Hiekkalinna & Sampo Sammalisto, 2004