Ignoring data when viewing and comparing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    Ignoring data when viewing and comparing

    Hi,

    I was wondering how I could get BC to completely ignore data between 2 unique tags and also not display that data in the UI.

    e.g. Hello Wo%$% foo %$%rld -> Hello World

    would not be highlighted as different and the left side would simply show "Hello World", not "Hello Wo%$% foo %$%rld" in the UI to the user.

    My background is mainly in databases and web languages like Perl and PHP, so I havent had much exposure to C or Delphi.

    The idea is that BC will be used to compare old and new data, allowing the user update the database without affecting other peoples updates...almost like a revision system for a database. The info between the unique tags will be result data, which needs to be tied to each line of information.

    Any ideas how I might attack this?

    Thanks!
  • chrroe
    Pooh-Bah
    • Oct 2007
    • 588

    #2
    Re: Ignoring data when viewing and comparing

    Hi!

    As far as I know, BC is not able to hide any part of lines in the fileviewer.
    One approach might be to write a conversion-batch-file for that type of files. In that batch you must use a program which is able to temporarily manipulate the files in that way which you want.

    Look at these two pages, maybe there is a helpful application:

    http://www.tinyapps.org

    http://gnuwin32.sourceforge.net


    Bye
    Christoph

    Comment

    • Guest's Avatar

      #3
      Re: Ignoring data when viewing and comparing

      Thanks for that, I managed to find Exam Diff Pro which supports the ignorance of lines and part of lines matching regular expressions...however the problem is everyone will have to have this installed under license...we have BC installed as standard on all machines, so theres the money issue and the versatility of it as well.

      Is there no way a plugin for BC could address even part of the problem? For example, display everything in the UI but just ignore parts of lines that match a regex, & not highlight it?

      Thanks for you help!

      Comment

      • Ernie
        Fanatic
        • Mar 2004
        • 137

        #4
        Re: Ignoring data when viewing and comparing

        I don't know if this will be exactly what you are looking for, but I use BC2 to compare source files kept under CVS source control. Different revisions of the source files all contain a revision tag similar to:
        Code:
        $Id: {filename},v x.xx yyyy/mm/dd hh:mm:ss {user} Exp $
        I have setup a regular expression in the Unimportant Text comparison rules to ignore common CVS revision tags. For this tag, I have added:
        Code:
        \$Id:.+\$
        The text within the $Id$ tag is still displayed in BC2, but not highlighted as long as "Ignore Unimportant Differences" is enabled.

        Comment

        • Zoë
          Team Scooter
          • Oct 2007
          • 2666

          #5
          Re: Ignoring data when viewing and comparing

          BC can do the same thing that you have ExamDiff Pro set up to do, which is ignore the text for the purpose of comparison. If you want the text removed from the display you'll need to use an external converter like Christoph suggested, but AFAICT ExamDiff Pro doesn't support that either. If you need help setting an external converter up let us know.

          To ignore the text for comparison purposesl ike ExamDiff does, follow these steps:
          <ul type="square">[*]Load your files and select "Edit Current Rules" from the Tools menu.[*]In the "File Comparison Rules" dialog change to the "Importance" tab and click the "New" button in the "Unimportant Text" box.[*]In the new "Unimportat Text" dialog you should be able to keep the category as "Delimited". Just put "%$%" in both the "Beginning with:" and "and ending with:" edits. You can use regular expressions instead, though they can't span multiple lines.[*]Click "OK" in both dialogs and the text should switch from red to blue, indicating that it's an unimportant difference, and the comparison will say it's "Similar" instead of "Different".[*]To ignore those differences completely select "Ignore Unimportant Differences" from the "View" menu, which will make those differences switch to black on white just like the regular text.[/list]
          Zoë P Scooter Software

          Comment

          • Guest's Avatar

            #6
            Re: Ignoring data when viewing and comparing

            Hi, thanks that helped a lot. Certainly a lot easier than ExamDiff! I am wondering though if it is possible to have BC already configured to ignore the delimiter...it could become a bit tedious going through that process every time to compare files and most wont actually realise why they are doing it or what its for.

            An external converter might be more tidy for the purposes of the user, as they arent actually meant to see this result data and wont have any idea what it means. Also there is the possibility they could edit it, so when it is uploaded back into the DB the results will be different/corrupted. In short, ignoring what is between these delimiters in the UI would be extremely useful, so any help on how to do this would be very appreciated!

            Thanks again, Steve.

            Comment

            • Chris
              Team Scooter
              • Oct 2007
              • 5538

              #7
              Re: Ignoring data when viewing and comparing

              Once you change the setting, it will be saved in your file comparison rules. BC picks the file comparison rule to use based on file extension. If more than one rule has a matching extension, it will use the first rule that matches, starting from the top of the rules list.

              To see and edit your rules, go to the Rules section of BC's Tools|Options dialog.

              If you want to share your rule with other users, use the Tools|Export Settings and Tools|Import Settings commands.

              You can configure an external conversion tool in the Conversion tab of the File Comparison Rules dialog. You can get to the dialog by either selecting Tools|Edit Current Rules in the File Viewer, or by selecting a rule and clicking Edit in the Rules section of Tools|Options.

              As an example, if you have a conversion tool named foo.exe that takes a source file and target file as an argument, in the Conversion tab, select "External Program" for the conversion type, and enter "foo.exe %s %t" for Run when loading:. %s and %t will be expanded with the source and target filename.

              As far as a conversion tool, you can write a converter in your favorite scripting language. We've also heard good things about TextPipe Pro for text manipulation.
              Chris K Scooter Software

              Comment

              • Chris
                Team Scooter
                • Oct 2007
                • 5538

                #8
                Re: Ignoring data when viewing and comparing

                A suggestion from Craig:

                A free alternative to TextPipe is sed

                Sed Win32 port: http://unxutils.sourceforge.net/
                Sed Tutorial: http://www.grymoire.com/Unix/Sed.html
                Chris K Scooter Software

                Comment

                • Zoë
                  Team Scooter
                  • Oct 2007
                  • 2666

                  #9
                  Re: Ignoring data when viewing and comparing

                  If you decide to go with an external converter I'd recommend 'sed', which is available at http://unxutils.sourceforge.net/. There's a tutorial for it at http://www.grymoire.com/Unix/Sed.html. You do need to wrap things in a batch file, since BC doesn't handle console redirection, but otherwise it's a pretty straight-forward thing.

                  Here's the batch file:
                  sed.exe %1 %2 > %3

                  And the external command for your files would be:
                  sed.bat s/%%$%%.*%%$%%//g %s %t

                  The batch file is generic so you can use it for multiple rules. The command just tells it to remove any text between %$% and %$%. The only weird part is that you have to double the % characters, since BC uses it as an escape character. If you were including that part directly in the batch file it would be:
                  sed.exe s/%$%.*%$%//g %2 > %3
                  Zoë P Scooter Software

                  Comment

                  • Guest's Avatar

                    #10
                    Re: Ignoring data when viewing and comparing

                    Would this not remove what is between %$% and %$% completely, not just hide it from the UI?

                    Also i'm having a bit of a problem getting sed to work...from the command line it isnt recognised even though the win32 sed version has been installed.

                    I have installed it under cygwin, which works, but it complains about the %2 > %3, where % is an unknown command...I cannot find this syntax in the sed tutorial anywhere.

                    In my batch file I have sed.exe s/%$%.*%$%//g %2 > %3
                    and BC calls sed.bat as an external program, the result is BC displays 2 blank view panes.

                    Apologies if the fix is pretty simple...never touched on batch files or indeed sed before now!

                    Thanks for your continued help!

                    Comment

                    • Zoë
                      Team Scooter
                      • Oct 2007
                      • 2666

                      #11
                      Re: Ignoring data when viewing and comparing

                      Yes, using sed would remove the text completely. Your choices are either that or ignoring the text, which was covered already. We don't support just hiding it from the display, and I honestly can't see that changing in the foreseeable future. We're moving towards inline editing, and selectively hiding text would complicate things immensely.

                      Anyway, if you have the %$%.*%$% part embedded in the batch file, instead of passed from the rules, you'll need to change the %2 and %3 to %1 and %2, respectively. That's part of the batch file syntax and they're replaced by the arguments to the batch file (the source and target filenames, passed in from BC). The > redirects the sed output from stdout to the target file, again done by the command processor (cmd.exe or command.com), so sed shouldn't see it.

                      The only thing that sed should see as it's arguements is:
                      sed.exe s/%$%.*%$%//g C:\somefilename.txt
                      Zoë P Scooter Software

                      Comment

                      Working...