Merge duplicate rows in CSV but prioritize row with the most complete data in the first 2 columns

Hi all,

I have a CSV which is like this (example):

OldDevice,NewDevice,Serial,Site 198273,419382,AKILSDJH,Some site 198273,,AKILSDJH,SiteA 198273,,AKILSDJH,SiteA ,419382,,A-Site 198273,,AKILSDJH,SiteA 198273,41938,AKILSDJH,Some site 198273,419382,AKILSDJH,Some site ,419382,,A-Site ,419382,,A-Site ,419382,,A-Site 

How would I go about fixing it so that I just end up with this:

OldDevice,NewDevice,Serial,Site 198273,419382,AKILSDJH,Some site 

I tried Sort -Unique with both the first and second properties but both sorts return blank entries.

This should be something I should be able to figure out but brain’s not working at the moment, so thought I’d admit defeat and ask the help of you fine folks. 🙂

Thanks!

submitted by /u/dextersgenius
[link] [comments]

Leave a Reply