View previous topic :: View next topic
|
Author |
Message |
nartcr
New User
Joined: 06 Jun 2007 Posts: 83 Location: anada
|
|
|
|
I am trying to code something with Syncsort.
Code: |
FILE1 FILE 2
COLUMNS COLUMNS
12345678901234567890 12345678901234567890
-------------------- --------------------
R1TEST1 NARA TEST1 REC1 NARA HOME
R2TEST1 NARA TEST2 REC1 NARA LIBRA
R2AMER1 NARA TEST2 REC1 AMAR GROUN
R2AMER2 RAJE AMER1 REC1 NARA MOVIE
R2TEST1 AMAR
FILE 3
COLUMNS
12345678901234567890
--------------------
R1TEST1 NARA HOME
R2TEST1 NARA HOME
R2AMER1 NARA MOVIE
R2AMER2 RAJE NMTCH
R2TEST1 AMAR NMTCH |
I have 2 input files of same length - 20 bytes. Field1 ( File 1, position 3 onwards for 5 bytes ) have to be compared with Field1 ( file 2, position 1 onwards for 5 bytes ). If they match, i want the field2 ( file 1, position 10 onwards for 4 bytes ) have to be matched with field 2 ( file 2, position 12 onwards for 4 bytes ). If i have a perfect match, i willl update the output file with last 5 bytes of output file, with contents of file 2.
output will have 1-15 contents copied from file 1. 16-20 contents from file 2. If there is match on field1 and field2, 16-20 should contain contents from file 2, otherwise it should contains the letters 'NMTCH'.
I have been reading the manuals, and i am kind of confused with sort keys. Especially since key is not unique here. i tried coding with sequence number. Is this even possible to code wih syncsort or icetool? Or should i code using programs instead? |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3051 Location: NYC,USA
|
|
|
|
why to make it difficult? you have to add these two fields (what you explained above) in the JOINKEYS then reformat fields as per what you want once you have that then make a use of parameter marker (?) to set NMATCH by using IFTHEN WHEN in the OUTREC |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
The keys are the things you are going to match on. Multiple key elements give you one logical key. If your logical keys can be duplicate, on one file or both, then you need some code in SORT to deal with that. There's a question form last week or so, perhaps in the DFSORT part of the forum, which goes into this. It is not difficult. |
|
Back to top |
|
|
|