in reply to Compare CSV files
Otherwise, if your requirements are more difficult, here is an example in Perl for the case of needing whole lines of file 1 in original order:cut -f3 -d, <file1.csv | sort -u >file1.cut.sort cut -f3 -d, <file2.csv | sort -u >file2.cut.sort comm -23 file1.cut.sort file2.cut.sort
use strict; use warnings; my $file2 = {}; open my $fh2, "<file2.csv"; while( <$fh2> ) { chomp; my @fld = split /\,/; $file2 -> { $fld[2] } = 1; } close $fh2; open my $fh1 "<file1.csv"; while( <$fh1> _ ) { chomp; my @fld = split /\,/; defined( $file2 -> { $fld[2] } ) and next; print "$_\n"; } close $fh1;
-M
Free your mind
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Compare CSV files
by Ovid (Cardinal) on Jul 19, 2006 at 16:00 UTC | |
by davorg (Chancellor) on Jul 19, 2006 at 16:07 UTC | |
by Moron (Curate) on Jul 19, 2006 at 16:07 UTC |