Page 1 of 1

Compare records with same key

PostPosted: Tue Sep 12, 2017 10:54 pm
by cuautli
Hi,
I need an output file with only one registry per key with two values
pos 2: 1 - When the input register contains the values 101 or 103 or 104
pos 3: 1 - When the input register contains the values 109 or 108

Input File
A107
A108
A109
B103
B104
C109

Output file
A11
B10
C01

Can you help me?
Thanks

Re: Compare records with same key

PostPosted: Wed Sep 13, 2017 12:53 am
by enrico-sorichetti
Can you help me?


NO :mrgreen:
Your terminology is confusing
the output is not consistent

Re: Compare records with same key

PostPosted: Wed Sep 13, 2017 3:50 pm
by Aki88
Hello,

Mr. Sorichetti, the TS has worded the post poorly, but looks like below is the requirement:

For the below input data:
A107
A108
A109
B103
B104
C109


The first character, A/B/C - in this case - act as the primary group item; program needs to test whether the remaining 3 characters fall under: 101/103/104 OR 109/108.

If the input characters fall under 101/103/104, then the second byte in the output needs to be 1; if the characters fall under 108/109, then the third byte of the output record needs to be 1; hence the output form:


<Group-element><data-bit 1><data-bit 2>
A11
B10
C01
 

Re: Compare records with same key

PostPosted: Wed Sep 13, 2017 4:02 pm
by Robert Sample
Except why is the output A11? There is no 101, 103, or 104 for the A -- so why is the output not A01? As was said, the output is not consistent with the stated requirements.

Re: Compare records with same key

PostPosted: Wed Sep 13, 2017 5:42 pm
by enrico-sorichetti
Mr Aki88 review the output and meditate please

the TS told nothing about what should be done with the other byte involved

when checking <byte one> of the result file the same decision will be taken for the A and B records
and the A and B record are in different sets in the original input

Re: Compare records with same key

PostPosted: Wed Sep 13, 2017 8:23 pm
by cuautli
Hi,

There are two groups of values G1={101,102,103} and G2={108,109}

When a same key has only values from group G1, the output record must be K10
When a same key has only values from group G2, the output record must be K01
When a same key has values of both groups G1 and G2, the output record must be K11

I have a long solution
1. Build a file with keys of group G1
2. Build a file with keys of group G2
3. Matching Records + Non Matching from both files

But perhaps there is a better solution.