Returnini non-unique data from a csv file

This topic contains 1 reply, has 1 voice, and was last updated by Profile photo of Gerald Gerald 1 year, 6 months ago.

  • Author
  • #24469
    Profile photo of Gerald

    I'm looking for a way to sort a csv file on unique values in 3 columns. In addition to returning the unique data, I also need to know what the non-unique(duplicate) data was so I can report on it(i.e. what was dropped).

    $uData below gives me the unique data I'm after –

    $data = import-csv $InputFile -header("A","B","C","D","E","F","G")
    $uData = import-csv $InputFile -header("A","B","C","D","E","F","G") | Sort C,D,E -unique 

    To find the non-unique I tried a compare, though it is returning data that is unique, not that which was dropped –

    compare-object $data $uData -passthru | Select C,D,E | ft

    Any thoughts how how I can determine non-unique data in this scenario?


  • #24470
    Profile photo of Gerald

    Nevermind, found my issue. It should be –

    compare-object $zdata $Data -property C,D,E -passthru  | ft

You must be logged in to reply to this topic.