Code:
Input:
header 1,header2,header3,header4,...,header29,header30,header31
vvv,www,xxx,yyy,...,zzz,longer,"really, darn, long, entry"
vvv,www,xxx,yyy,...,zzz,short,"not,so,long"
123,yyy,zzz,aaa,...,bbb,short ,"really, darn, long, entry"
123,yyy,zzz,aaa,...,bbb,longer ,"really, darn, long, entry"
123,yyy,456,aaa,...,bbb,short,"really, darn, long, entry"
Output: (sorting would be nice but not required unless the implementation requires it)
header 1,header2,header3,header4,...,header29,header30,header31
vvv,www,xxx,yyy,...,zzz,short,"not,so,long"
123,yyy,zzz,aaa,...,bbb,short ,"really, darn, long, entry"
123,yyy,456,aaa,...,bbb,short,"really, darn, long, entry"
When the partial rows in bold are not unique keep the one where the total length of the last two columns concatenated is shortest.