in reply to Removing doubles and printing only unique values
I strongly recommend you use Text::CSV for CSV input/output, your script will end up much more robust and probably a bit shorter (also install Text::CSV_XS for speed). I gave an example of CSV input and output here. Update: Copied over code example (with minor adaptations):
use warnings; use strict; use Text::CSV; my $csv = Text::CSV->new({ binary=>1, auto_diag=>2, eol=>$/, sep_char => ";" }); open my $ifh, '<', 'Input.CSV' or die $!; open my $ofh, '>', 'Output.CSV' or die $!; while ( my $row = $csv->getline($ifh) ) { # your logic to modify data here $csv->print($ofh, $row); } $csv->eof or $csv->error_diag; close $ifh; close $ofh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Removing doubles and printing only unique values
by zarath (Beadle) on Oct 31, 2017 at 13:53 UTC |