Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


RE: Comparing 2 files

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,30370
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> RE: Comparing 2 files
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: <<   < prev  1 [2]
Login
Message << Older Topic   Newer Topic >>
 RE: Comparing 2 files - 2/2/2006 2:05:44 AM   
  ehvbs

 

Posts: 2061
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi hamboy,

sorry about

  (a) posting before reading
  (b) the ado error

(b) may be caused by calling (the old version of) getdispSqlNice() for an empty recordset.
Try the new version from my last (monster) posting.

ehvbs

< Message edited by ehvbs -- 2/2/2006 2:07:01 AM >

(in reply to ehvbs)
 
 
Post #: 21
 
 RE: Comparing 2 files - 2/2/2006 4:30:46 AM   
  hamboy

 

Posts: 94
Score: 6
Joined: 7/11/2005
Status: offline
hi ehvbs,

thanks for the monster post... I enjoy the humor (and no i'm not a warden LOL).
My data are actually locations of communication towers and each element ID (ie. P-*) is the ID assigned to a communication tower.
basically map.txt is the data output of each communication tower from 1 system, and report.csv is output of the communication tower from another system.
the objective was to compare the data from both systems to see if there are any discripancies.


After going through your monster posts, I can sort of make sense some parts, but I can't really get everything together.
Your previous post (1/31/2006 8:39:34 AM) works perfectly for report.csv where it lists all of the data in a nice accessible format.

Were you able to do the same for map.csv? I assume it would be easier to work with since there's no "junk" data that needs to be ignored.
Once the two files are in nicely accessible format, map.txt needs to be compared agaiinst report.csv for any discrepancies and output any differences of Cell/Reporting System using on Element ID as key to an "Unmatching" list. If Element ID from map.txt does not exist in report.csv, then it should be outputed to "Not found" list.

Is it possible to post the entire contents of each file in individual code tags so it's easier to make sense what's what?

< Message edited by hamboy -- 2/2/2006 4:35:49 AM >

(in reply to ehvbs)
 
 
Post #: 22
 
 RE: Comparing 2 files - 2/2/2006 4:59:49 AM   
  ehvbs

 

Posts: 2061
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Hamboy,

thanks for the info! While I think about it, I propose that you look at Navarre's "file check" topic.
It is about compareing data from two sources about the same items too, and I will post a demo
using (RegExps and) dictionaries to find matching/missing/contradictory information. Perhaps
you will feel more familiar with this approach. (Or you could post a small set of data from your
domain showing the different cases you are interested in.)

ehvbs

(in reply to hamboy)
 
 
Post #: 23
 
 RE: Comparing 2 files - 2/2/2006 5:19:53 AM   
  hamboy

 

Posts: 94
Score: 6
Joined: 7/11/2005
Status: offline
To assist in the explaination, Lets say after report.csv & map.txt have been formatted:

report.csv sample data

      

map.txt sample data


      

Sample Output

      

(in reply to ehvbs)
 
 
Post #: 24
 
 RE: Comparing 2 files - 2/2/2006 5:59:37 AM   
  ehvbs

 

Posts: 2061
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi hamboy,

the easy part first: That's my current set of source files:

(1) schema.ini: used by the ADO/Text driver; he/she/it (?) makes the files
    of one directory specified as DBQ in the connection string accessible
    as tables defined by the sections [<filename>] in schema.ini. You may add
    definitions to this file freely as long as you keep the filenames unique.
    Deleting/hiding sections by commenting out the [<filename>] section
    title, however, may break existing code.


      

(2) library.vbs: a set of functions/subs/classes that can be loaded into
    the namespace of a .vbs script by something like

       ExecuteGlobal goFS.OpenTextFile( "library.vbs" ).ReadAll

    Adding to this file is no problem; reworking existing code is not
    without danger (as old code using the library may break), but if
    you are carefull, old code may even profit from your changes.


      

(3) frstest.vbs: a main test script having three important parts:

    (a) the library loading (see above)

    (b) the (low tech) main sub call 'dispatcher'

        WScript.Quit doPrisonCheck()
        WScript.Quit doFrsCmp()
        ....
        WScript.Quit doOLdFormat()
        WScript.Quit doMain00()

    (c) the main subs, basically

        Function doXXXX()
          Dim oCN : Set oCN = newAdoCN( Array( "text", ".\" ) )
          Dim sSQL, aFields, ....

          sSQL    = "SELECT blah FROM blahblah"
          getdispSql oCN, sSQL, "|"
          getdispSqlNice oCN, sSQL, "|"

          doXXXX = 0
        End Function

    The three parts together should allow you to use a (increasing) amount
    of tested code (library.vbs) to try something out (in the different main
    subs) while switching between them by reordering or [un]commenting the
    WScript.Ouit doThisOrThat() calls.


      

    For some time it's a pro that you may refer to code you played
    around with yesterday when you search for better ways tomorrow.
    But it will become more of a con when the size of the file
    increases. So just start afresh with a minimal sectest.vbs


      

(in reply to hamboy)
 
 
Post #: 25
 
 RE: Comparing 2 files - 2/2/2006 6:15:41 AM   
  hamboy

 

Posts: 94
Score: 6
Joined: 7/11/2005
Status: offline
cool cool... it makes a lot more sense now...
btw...what is sectest.vbs (your last posted code) for? it does not output anything

Just for clarification, example data: "P-MON-OMP-1:314" : "P-PQ0506", comparison is done with 4 things "MON", "1", "314", "P-PQ0506", which you have already done so it's cool.

however, when i ran the code it gave me error:
quote:

C:\vscript practice\commtower>cscript frstest.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.
##### Warden ehvbs doing his check
***** Who was/is sitting where?
C:\Documents and Settings\mahkar\Desktop\test2\frstest.vbs(0, 1) Microsoft OLE D
B Provider for ODBC Drivers: [Microsoft][ODBC Text Driver] The Microsoft Jet dat
abase engine could not find the object 'prisoners_in_cells.csv'.  Make sure the
object exists and that you spell its name and the path name correctly.






To help on the testing... I've done the "process "of what the script should do in excel:
http://s49.yousendit.com/d.aspx?id=2AK6HY2LG0F0K2W3W1H31AKHRB

The outoupt should have the exact data and a similar format like this:

      

< Message edited by hamboy -- 2/2/2006 6:47:45 AM >

(in reply to ehvbs)
 
 
Post #: 26
 
 RE: Comparing 2 files - 2/2/2006 9:11:38 AM   
  ehvbs

 

Posts: 2061
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi hamboy,

we keep each other occupied! While you where working with Excel, I filled the empty frame of sectest.vbs
like this: