Inspired by a recent SoPW, how short can you write a diff of two simple csv files that displays the missing keys from the two files prefixed by the fileno they were missing from?
Some test data:
P:\test>type t1.csv 1,the,rest 2,the,rest 3,the,rest 4,the,rest 5,the,rest P:\test>type t2.csv 2,the,rest 4,the,rest 6,the,rest 8,the,rest
And my best that at 114 strokes can surely be well beaten?
Rules: Command, including all switches count; filenames don't.
# 23456789 123456789 123456789 123456789 123456789 123456789 123456789 + 123456789 123456789 123456789 123456789 1234 perl -anF, -le"$h{$F[0]}=1;eof&&last}{$h{(split',',$_)[0]}--while<>;$h +{$_}&&print $h{$_}<0?'1:':'2:',$_ for keys%h" t1.csv t2.csv 1:8 1:6 2:1 2:3 2:5
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: [GOLF] Perl csv diff
by truedfx (Monk) on Nov 03, 2005 at 13:25 UTC | |
by BrowserUk (Patriarch) on Nov 03, 2005 at 13:50 UTC |