View Single Post
Old 07-06-2007   #6 (permalink)
Kiron


 
 

Re: Compare 2 files with 6,000 entries each

Is the matching list (users.csv) made up of unique user names?
The containment operators (-contains and -notcontains) will stop checking if
the right operand is present in the left operand and move on to compare the
next object in the pipeline.

0..7 | where-object { 1, 3, 5, 3 -contains $_ }
1
3
5

It only returns 3 once. The 'old way' was matching against each element, if
there were repeated users in $csv you would have more results. Hence the
unique users list question. Note the use of where-object, Jacques is right,
this way is more efficient than:

0..7 | foreach-object { if(1, 3, 5, 3 -contains $_) {$_} }

--
Kiron

My System SpecsSystem Spec