0

I'm trying to output a file containing only the rows that have 3 duplicate values with 3 columns.

Csv Current Example:

I only want to find duplicates on columns (2, 3, and 5), then output these rows to a results csv file

Column1,Column2,Column3,Column4,Column5,Column6
1a,32,46,1,1111,poiu
2b,12,43,123,3333,zxcv
3c,12,36,344,5555,asdf
4d,12,36,64,5555,qwer
5e,12,36,22,8888,lkjh
6f,10,36,5432,7777,mnbv

The results csv file should have:

3c,12,36,344,5555,asdf
4d,12,36,64,5555,qwer

Can anyone tell me how I can do this?

1 Answer 1

2

Group by those columns, filter for groups that have more than 1 entry, expand those groups, export to csv.

Import-CSV $File | group Column2,Column3,Column5 | Where{$_.Count -gt 1} | Select -Expand Group | Export-CSV $Output -Noheader
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.