hanger4 has asked for the wisdom of the Perl Monks concerning the following question:
There are two input files, an ID file of 3 columns and a Name file of four columns (the actual data are large ~ 100,000 rows):
ID file:
ID Catg_ID Pos
12 A 16
15 B 5
16 A 175
Name file:
Catg_Name Start Stop Name
A 8 19 jamm
A 110 112 bbc
E 170 256 vadd
A 14 18 cip
For each row in the ID file, I need to compare the Catg_ID variable to the Catg_Name variable in the Name file. Then, if the catg variables match, I want to see if Pos is between Start and Stop. For rows that meet both the above criteria, I want to combine them in a single output file.
So, to recap, IF Catg_ID = Catg_Name AND Pos > Start AND Pos < Stop I want to print "ID Catg_ID Pos Name"
And just to be clear, I need to compare not the first line in the ID file to the first line in the name file, but the first line in the ID file to every line in the name file, then the second line in the ID file to every line in the name file, and so on. Multiple matches are fine.
For the above data, I would want the program to print:
12 A 16 jamm
12 A 16 cip
Thanks in advance. I've tried to be as clear and specific as possible.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing multiple entries from two files
by ww (Archbishop) on Jul 08, 2009 at 00:53 UTC | |
|
Re: Comparing multiple entries from two files
by jethro (Monsignor) on Jul 08, 2009 at 00:19 UTC | |
|
Re: Comparing multiple entries from two files
by hobbs (Monk) on Jul 08, 2009 at 07:56 UTC | |
|
Re: Comparing multiple entries from two files
by bichonfrise74 (Vicar) on Jul 08, 2009 at 17:01 UTC | |
by hanger4 (Initiate) on Jul 08, 2009 at 21:21 UTC | |
by toolic (Bishop) on Jul 08, 2009 at 23:31 UTC | |
by Anonymous Monk on Jul 09, 2009 at 00:06 UTC |