跳过或删除“镜像”数据的算法

问题描述 投票:0回答:0

我正在阅读一个看起来像这样的文件:


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         2942                   mother         son
6             3911         3910                   mother         daughter
7             3911         3912                   mother         daughter
8             3911         5062                   wife           husband

正如您在此数据中看到的,第 1 行是第 5 行的副本,但翻转了。我想对这样的行进行重复数据删除,只保留一对。我在下面尝试了这个算法,但它删除/跳过所有这些行而不是重复数据删除。我将把 ttRelationship 中的所有值读取到一个文件中作为我的目标,这将是我的去重文件。有什么想法吗??我很难过。

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.


openedge progress-4gl
© www.soinside.com 2019 - 2024. All rights reserved.