Processing a transaction file against a master

Welcome Forums General PowerShell Q&A Processing a transaction file against a master

Viewing 8 reply threads
  • Author
    Posts
    • #210600
      Participant
      Topics: 1
      Replies: 3
      Points: 19
      Rank: Member

      Need advise on the best and fastest way to do this.

      Let’s say I have a transaction file with 1000 computer names in it, 1 per line.

      Then I have a master file with 20000 lines that as part of the line data, contains a computer name but with other attributes.

      I need to read the transaction file to get the computer name, then read the master to get an attribute if the record matches on the computer name.

      I have tried foreach inside foreach and runs too dam long.  I have also tried compare-object and didn’t get far.

      What is the best way to accomplish what it is I am after?

       

    • #210606
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      Please help us to help you. You should post along with the code you already have A FEW REPRESENTATIVE LINES of both files you mentioned above. You should format all of this as code using the code tags “PRE”. You may read the instructions about this forum in the very first post of this forum: Read Me Before Posting! You’ll be Glad You Did!. Thanks

    • #210612
      Participant
      Topics: 1
      Replies: 3
      Points: 19
      Rank: Member

      Transaction file contains:

      server2
      server7
      server9

      Master contains:

      server1 attribute1
      server2 attribute2
      server3 attribute3
      server4 attribute4
      server5 attribute5
      server6 attribute6
      server7 attribute7
      server8 attribute8
      server9 attribute9
      server10 attribute10

      I lookup 2, 7 and 9 and get back attribute2, attribute7 and attribute9

    • #210618
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      Hmmm … your code and a few lines of your files FORMATTED AS CODE please. Please read the instructions I linked for you. Please do not create a new post – edit your existing first one.
      Thanks.

    • #210627
      Participant
      Topics: 1
      Replies: 3
      Points: 19
      Rank: Member

      No code, hence why I started this thread.

    • #210645
      Participant
      Topics: 12
      Replies: 527
      Points: 1,247
      Helping Hand
      Rank: Community Hero

      One foreach loop with ‘where-object’ to match..
      This will work as long as the record counts in the input files is small enough to load in memory…

    • #210648
      Participant
      Topics: 1
      Replies: 3
      Points: 19
      Rank: Member

      Thank you!

    • #210660
      Participant
      Topics: 5
      Replies: 328
      Points: 522
      Helping Hand
      Rank: Major Contributor

      The test below took 3 seconds to process 20K rows.

    • #210798
      Participant
      Topics: 13
      Replies: 1758
      Points: 3,153
      Helping Hand
      Rank: Community Hero

      I was doing the same thing as @random commandline, but I’m not sure about the switch vs just a where:

Viewing 8 reply threads
  • The topic ‘Processing a transaction file against a master’ is closed to new replies.