Hello,
My boss came to me with a large assignment today, and the first step involves combining the data from 2 different files using a number common in both as an index.
The files look as follows
1st file:
20722|20723|3 1 6 0 1 2484 19488|
9400|9401|3 1 6 0 1 2484 14087|
9400|9402|3 1 6 0 1 2484 14088|
16582|16583|3 1 6 0 1 2484 19239|
16582|16584|3 1 6 0 1 2484 19240|
20722|20724|3 1 6 0 1 2484 19489|
27347|27348|3 1 6 0 1 160 14342|
25408|25409|3 1 6 0 1 2484 37107|
25408|25410|3 1 6 0 1 2484 37108|
Second file:
6724|20722|pa0598KingsManor|26870|567|
6871|18377|pa0179Ithan|26386|440|
22372|22373|SITE-0|||
5293|9079|nj5056Hammonton|166|88|
19435|30497|nj5007Paulsboro|46|3|
6871|23106|pa0210Manatawny|26363|636|
14862|23026|de0742CrossKeys|27865|514|
1362|29489|SITE-0|||
14862|18468|pa0376Dartmouth|27345|424|
10469|29899|PPA051P_WestGate|26885|706|
6871|30955|pa0075Cedarville|322|163|
This is how the files have to be combined. The first column in the first file, corresponds to the second column of the second file. So what I need help with is, printing the new file as follows. The second column from the first file, then the first column of the first file, then the corresponding 3rd column from the second file.
So, for example,
20722|20723|3 1 6 0 1 2484 19488| from the first file corresponds to the
6724|20722|pa0598KingsManor|26870|567| on the second file because the 1st column in file 1 matches the second column in file 2. In this case, i would want
20723|20722|pa0598KingsManor| printed on the new file.
Thank you very much for all your time and help.
Dipul
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.