Csaba
Wed Jul 20 15:07:25 CDT 2005
Antknee wrote:
> Hi. I have two text files that are actually exports of user and computers
> accounts from two domains. I would like to be able to compare the two files
> for duplicate names and spit out a "report" of the unique names and duplicate
> names.
Perhaps one of the suggested file comparison programs will work for
you. However, if the name order between files is not well correlated
(e.g. alphabetized), your file comparison program(s) may become
confused.
Another possible approach is to use a dictionary and parse each file
one line at a time. Specifically, create an empty dictionary (Set
dct=CreateObject("Scripting.Dictionary")) and for each line in the
first file, add it as a key/value pair to the dictionary (dct.Add key,
itemValue -you haven't said exactly what you are comparing).
Now you will parse the second file. For each line check to see whether
it's in the dictionary (dct.Exists(item)). If so, then it is a name
common to both files (and now either delete it or mark it as seen,
somehow). If not, it is a name unique to the 2nd file. Finally,
iterate through the dictionary (For each item in dct) and every
remaining entry is a name unique to the first file.
This code is compact, efficient, and local.
There is a Jun 20, 2005 example titled
Compare the values of two sorted arrays of variable size
at
http://groups-beta.google.com/group/microsoft.public.scripting.vbscript/browse_frm/thread/79770dda5c1b0bcb/d7a31ba39698a3ba
Good luck,
Csaba Gabor from Vienna