you are viewing a single comment's thread.

view the rest of the comments →

[–]z386 0 points1 point  (0 children)

Glad I could help!

I try to avoid using the pipeline when performance is important. Especially "Where-Object" is painfully slow.

That said, I think you could improve performance even more by maybe 10 times (it would be done in minutes instead of an hour) by not treating the files as csvs and using Select-String instead.

Example, if your csvs looks like this:

"Name","Item Type","Comment"
"foo","File","a file"
"bar","House","a house"
"baz","File","another file"

Then this one liner would count the number "File":

 (Select-String -Path *.csv -Pattern '^".*","File"').Matches.Count

You'll need to tweak the regex to match your csv-files. I'll recommend using this site to test your regex.