remove duplicates (but only on specified key)

remove duplicates (but only on specified key)

1
NewbieNewbie
1

    Apr 03, 2005#1

    hello all,

    this may be posted to the wrong forum, if so, i apologize.

    i am trying to remove records that have been sorted on a
    key that have the same key (the other fields may be equal/different).
    basically i want the feature of advanced sort with the 'remove duplicates'
    looking at that specified key and NOT the entire record.
    here is an example of what i want:

    input:
    key1 anything2
    key1 anything1
    key2 anything1
    key2
    key2 anything2
    key3 anything5
    key3 111
    key4 222

    output
    key1 ....
    key2 ....
    key3 ....
    key4 ....

    is there a way to accomplish this ? a macro ?
    maybe in the future an enhancement to the
    'advanced sort, remove duplicates' can be at the field(key) level ?

    thanks

    261
    Basic UserBasic User
    261

      Apr 04, 2005#2

      You could try this macro:

      InsertMode
      ColumnModeOff
      HexOff
      UnixReOn
      Top
      Loop
      ToggleBookmark
      SelectWord
      Copy
      EndSelect
      Find "^c"
      IfFound
      DeleteLine
      GotoBookMark
      ToggleBookmark
      Else
      GotoBookMark
      ToggleBookmark
      Key DOWN ARROW
      Key HOME
      EndIf
      IfEof
      ExitLoop
      EndIf
      EndLoop

      This assumes a couple of things. First, you have the file sorted the way you want it. Second, the first record with a key is the one you want to keep. Third, there are no bookmarks in the file to begin with.

      If these conditions are met, I believe this macro will do what you want. As always, be sure to keep a copy of your file before you try it.

      Hope it helps!
      Dave
      ASTTMan
      I'm not a Texan, I just live here.

      26
      Basic UserBasic User
      26

        May 11, 2005#3

        This worked great with a couple of modifications this saved me hours of work!!! Thanks....