Process and compare records in single collection without repeating

Welcome Forums General PowerShell Q&A Process and compare records in single collection without repeating

Viewing 4 reply threads
  • Author
    Posts
    • #276765
      Participant
      Topics: 3
      Replies: 7
      Points: 53
      Rank: Member

      Hello,

      can you advise what should I search for in documentation. I do not know how to call what I am trying to do.
      I have a $collection with $record and need to process each to $records a compare it. But I do not want to compare same records and repeat the comparison.
      Dummy example of code:

      With the code above, it would compare:

      A-A (do not want)
      A-B
      A-C
      B-A (do not want)
      B-B (do not want)
      B-C
      C-A (do not want)
      C-B (do not want)
      C-C (do not want)

      It does not matter with 3 records, but I have collection with 80 000+ records. Is there a function or some trick for this? What should I look for?

      Thank you

      Honza

      • This topic was modified 1 month, 2 weeks ago by Honza.
    • #277725
      Participant
      Topics: 5
      Replies: 249
      Points: 985
      Helping Hand
      Rank: Major Contributor

      How about this?

       

    • #277737
      Participant
      Topics: 17
      Replies: 1951
      Points: 3,986
      Helping Hand
      Rank: Community Hero

      You have two sources with matching labels? Normally you would want to do some kind of join operation on the other recordset (e.g. Label) and build an object:

      Once you have the object, you can execute a filter on the results:

      While you can output a string or log, you are then reading it manually. If you use an object approach, you can see all of that data and can do comparisons and exports such as a csv.

    • #277749
      Participant
      Topics: 1
      Replies: 95
      Points: 435
      Helping Hand
      Rank: Contributor

      To me it is simplest to use a Queue object. You can Dequeue() (remove) the first object during each run to ensure no repeats.

      This is not going to be an efficient process without have presorted data or using another tool built for bulk comparisons/joins.

    • #278463
      Participant
      Topics: 3
      Replies: 7
      Points: 53
      Rank: Member

      Thank you guys.

      I think I found solution on my own. It is primitive, but it works.

       

      Thank you all. I am going to check your ideas anyway.

      Honza

       

Viewing 4 reply threads
  • You must be logged in to reply to this topic.