F
Felice
Guest
I am reading in a file that looks like this:
As you see in this data, line 1 is a duplicate of line 5, but flip-flopped. I want to dedupe rows that are like this and only keep one pair. I tried this algorith below, but it deletes/skips over all those rows rather than deduping. I am going to read all the values in ttRelationship out to a file as my goal, which will be my deduped file. Any thoughts?? I'm stumped.
Continue reading...
Code:
line# person-pin reciprocal-person-pin relationship reciprocal-relationship
1 2942 3911 son mother
2 3911 2560 client financial advisor
3 3911 1195 employee employer
4 3911 1190 church member church
5 3911 3942 mother son
6 3911 3910 mother daughter
7 3911 3912 mother daughter
8 3911 5062 wife husband
As you see in this data, line 1 is a duplicate of line 5, but flip-flopped. I want to dedupe rows that are like this and only keep one pair. I tried this algorith below, but it deletes/skips over all those rows rather than deduping. I am going to read all the values in ttRelationship out to a file as my goal, which will be my deduped file. Any thoughts?? I'm stumped.
Code:
FOR EACH ttRelationshipData:
FIND FIRST ttRelationshipData2 WHERE ttRelationshipData.constituent-pin EQ ttRelationshipData2.related-constituent-pin
AND ttRelationshipData.related-constituent-pin EQ ttRelationshipData2.constituent-pin NO-LOCK NO-ERROR.
IF AVAILABLE ttRelationshipData2 THEN NEXT.
ELSE DO:
CREATE ttRelationship.
ASSIGN
ttRelationship.alpha-pin = ttRelationshipData.constituent-pin
ttRelationship.alpha-role = ttRelationshipData.constituent-relationship-name
ttRelationship.bravo-pin = ttRelationshipData.related-constituent-pin
ttRelationship.bravo-role = ttRelationshipData.relatedconstituent-rel-name.
END.
END.
Continue reading...