With the same principle as brother Veltro, here is a take with some tests (whose number you can happily expand to your satisfaction). It uses Text::CSV_XS and thus allows for less strictly-formed inputs, should they arise. The final output of the normalised dataset is left as a simple exercise.

#!/usr/bin/env perl use strict; use warnings; use Test::More tests => 3; use Text::CSV_XS; my $csv = Text::CSV_XS->new; my %out; while (my $colref = $csv->getline (*DATA)) { next if exists $out{$colref->[0]}; $out{$colref->[0]} = [@$colref[1,3,4,5]]; } is (scalar (keys %out), 19, 'Have correct number of output lines'); is_deeply ($out{key_683}, ['march', 'ABCD_FH', 9, 9], 'First line is g +ood'); is_deeply ($out{key_701}, ['march', 'ABC_H + AB_F', 2, 19], 'Last line + is good'); __DATA__ key_683,march,29031990,ABCD_FH,9,9 key_684,march,29031990,ABCD_FH,9,9 key_685,march,29031990,ABCD_FH,9,9 key_686,march,29031990,ABCD_FH,9,9 key_687,march,29031990,ABCD_FH,9,9 key_688,march,29031990,ABCD_FH,9,9 key_689,march,29031990,ABCD_FH,9,9 key_693,march,29031990,ABCD_FH,9,9 key_694,march,29031990,ABCD_FH,9,9 key_683,march,29031990,ABCD_H + ABC_F,8,17 key_684,march,29031990,ABCD_H + ABC_F,8,17 key_685,march,29031990,ABCD_H + ABC_F,8,17 key_686,march,29031990,ABCD_H + ABC_F,8,17 key_687,march,29031990,ABCD_H + ABC_F,8,17 key_688,march,29031990,ABCD_H + ABC_F,8,17 key_689,march,29031990,ABCD_H + ABC_F,8,17 key_690,march,29031990,ABCD_H + ABC_F,8,17 key_691,march,29031990,ABCD_H + ABC_F,8,17 key_692,march,29031990,ABCD_H + ABC_F,8,17 key_693,march,29031990,ABCD_H + ABC_F,8,17 key_694,march,29031990,ABCD_H + ABC_F,8,17 key_695,march,29031990,ABCD_H + ABC_F,8,17 key_696,march,29031990,ABCD_H + ABC_F,8,17 key_697,march,29031990,ABCD_H + ABC_F,8,17 key_698,march,29031990,ABCD_H + ABC_F,8,17 key_699,march,29031990,ABCD_H + ABC_F,8,17 key_683,march,29031990,ABC_H + AB_F,2,19 key_684,march,29031990,ABC_H + AB_F,2,19 key_685,march,29031990,ABC_H + AB_F,2,19 key_686,march,29031990,ABC_H + AB_F,2,19 key_687,march,29031990,ABC_H + AB_F,2,19 key_688,march,29031990,ABC_H + AB_F,2,19 key_689,march,29031990,ABC_H + AB_F,2,19 key_690,march,29031990,ABC_H + AB_F,2,19 key_691,march,29031990,ABC_H + AB_F,2,19 key_692,march,29031990,ABC_H + AB_F,2,19 key_693,march,29031990,ABC_H + AB_F,2,19 key_694,march,29031990,ABC_H + AB_F,2,19 key_695,march,29031990,ABC_H + AB_F,2,19 key_696,march,29031990,ABC_H + AB_F,2,19 key_697,march,29031990,ABC_H + AB_F,2,19 key_698,march,29031990,ABC_H + AB_F,2,19 key_699,march,29031990,ABC_H + AB_F,2,19 key_700,march,29031990,ABC_H + AB_F,2,19 key_701,march,29031990,ABC_H + AB_F,2,19

In reply to Re: I want to remove duplicate based on specific column and value. by hippo
in thread I want to remove duplicate based on specific column and value. by EBK

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.