Since the key field (id) is initial on each line (and can
almost certainly be relied on as never needing quotes to
contain an embedded comma), the solution is quite simple, as
the earlier replies have shown, using hashes.
I wrote and posted a utility here, called cmpcol
that handles this directly as a command line:
cmpcol -d ',' -x1 -l1 oldlist newlist
That will treat use the first comma-delimited string on
each line of each file as a hash key, and print the set of
lines whose keys are unique to the first of the two files
(-x1, for exclusive-or set from file1, oldlist in this case).
It will also do intersection and union of the two lists.
By default, it only prints the key fields that meet the
stated conditions, but the "-l1" ("list full line of file1")
gives you what you want. If you wanted to compare old and
new data for people in both lists, you could do:
cmpcol -i -d ',' -lb oldlist newlist
(produce intersection, list full lines of both files).
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.