SPONSORS:






User Tag List

Results 1 to 4 of 4
  1. #1
    Senior Member
    Join Date
    Jul 2001
    Posts
    147
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Comparing two files and getting the difference.

    Hi All,

    I want to compare two text files to determine if there is a difference.

    If there is a difference, I want to print the line number from the text file that is different.

    How do I do that?

    ------------------
    Who Tests The Tester...
    Who Tests The Tester...

  2. #2
    Senior Member
    Join Date
    Mar 2000
    Location
    pisctaway, NJ USA
    Posts
    188
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Comparing two files and getting the difference.

    If you wanna do a dumb verify, then
    read the file into a list of string, and do:

    for each sLine in lsFile1
    iCount++
    if sLine != lsFile2[iCount]
    print("Line {iCount} doesnt match")


    I mean that is the MOST simple file compare.
    If you want something more complex, anything someone has on this board is probably not going to fit your needs since you will then get into defining what is a match? WHITE SPACES? Do we ignore TABS? Case sensitive? What about....get it?

    Tony

    ------------------

  3. #3
    Member
    Join Date
    Jul 2001
    Location
    NY, USA
    Posts
    67
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Comparing two files and getting the difference.

    try sys_comparetext and sys_verifytext functions of silk test

    cheers

    ------------------

  4. #4
    Senior Member
    Join Date
    Jul 2001
    Location
    Elizabeth, CO, USA
    Posts
    653
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Comparing two files and getting the difference.

    The problem with SYS_VerifyText is that if the files change between the failure and the end of the test, the difference viewer will show you the new files, not the ones that failed. As such, it's probably better to read the two ASCII files into two LIST OF STRING variables and just use Verify.

    Unfortunately, with that technique, if there are lines you don't want to compare (e.g.- the date, a salutation, etc.), then SYS_VerifyText or even reading the files into LISTs and Verifying will fail.

    Try this:

    That function will allow you to pass in a list of lines to exclude from the comparison. However, the argument is optional; if you don't need to exclude lines, just pass in the two filenames and a simple comparison will be performed using the LISTs so that the difference viewer will still show differences after the test has been run.

    - Dave


    ------------------
    Amelior Technology
    dreed@ameliortech.com
    WaltzingRhino.com
    A concerned Borland customer, a fly in the ointment, a wrench in the works.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 05:45 PM.

Copyright BetaSoft Inc.