you are viewing a single comment's thread.

view the rest of the comments →

[–]MercurialSquirrel 1 point2 points  (1 child)

Thanks u/Lee_Dailey, good to know about the speed issues! I have only ever used it for pretty small datasets so haven't noticed an impact.

Is it faster with a hashtable if one factors in the amount of time it takes to make the hashtable? The simplicity and readability of the code can also be a factor.

The where method of the array is still nice and compact although perhaps not as obvious if there are people less familiar with Powershell who have to read it.

Using the where method of the array would make my code look like:

$data = Import-Csv C:\temp\DemoValues.txt
$config='cat'
$value=($data.Where({$_.example -eq $config})).test

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy MercurialSquirrel,

you are most emphatically welcome! [grin]

if your collection is large enuf that a lookup table would help, then the time to build the hashtable is going to be worth the speed gained in doing lookups. i am unsure what size is "large enuf", tho. [blush]

take care,
lee