Jim wrote:
>  
> Hi 

Hello,

> I have csv file that has data something like this (Header in caps)
> 
> LOAN_NO,SCORE,BAL
> 77585,740,452125
> 77585,741,450256
> 85669,658,125869
> 85669,658,122586
> 
> Looking for ideas on the best way to skip/delete a line if the LOAN_NO
> repeat even if other fields ion in the record are not the same (need to
> remove lines with dup key fields). 
> The code below seems to work, but there must be a better way.
> Thanks for any help
> 
> Jim 
> -------------------------------------
> 
> # file already sorted by $id
> my $cur_id = '';
> while (<F>) {
>       chomp;
>       ($id,$score,$bal) = split (/,/, $_);
>       next if $cur_id == $id;
>       print OUT "$id,$score,$bal\n";
>       $cur_id = $id;
> }

Don't fix it if it's not broken.  :-)


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to