No announcement yet.

Data Compare plus scripting

  • Filter
  • Time
  • Show
Clear All
new posts

  • Data Compare plus scripting

    I’ve been using the Data Compare session type for a while now, and loving the way BC automatically parses my delimited files and allows me to easily define key columns and mark others as unimportant. Now I’m ready to automate some of my comparisons using the scripting language. Unfortunately it appears that BC doesn’t support loading Data Compare sessions (with predefined key and unimportant definitions) from within a script.

    I’ve been researching alternatives, and stumbled across the “regular expressions” capability. Would it be possible for me to use regular expressions to specify unimportant columns by saying something like “the fields after the 5th and 11th tab characters are unimportant”? Or is there some easier way to do this I’m missing?


  • #2

    Unfortunately, our Regular Expressions are not conditional, and we don't have a way to "count" up to the 5th tab without also including the previous tabs. We don't have a way to find just the text after the 5th tab and after the 11th tab.

    If the entire middle was unimportant, you could define the "beginning of line to the 1st tab, text, 2nd tab, text, etc, to the 5rd tab" as Important, and "text, tab, text, tab, text, end of line", then that could potentially work. Here is an example KB article with video:

    Are you attempting to generate a Data Compare Report, or something along those lines, with script?

    The method to load a Data Compare in script is a bit complicated in BC3, but doable. You create a parent Folder Compare session with saved child settings for your Data files. You can do so by configuring it in the graphical interface.

    First, you would create a Folder Compare session that points to your two files, aligned side by side. Do your two files reside in two different folders and have the same name? If so, you can simply set these two folders as your base folders. If your files have different names, or are in the same folder, this gets a little trickier. Do you have BC3 Pro or Std?

    Assuming we have a saved Folder Compare session with your two files aligned, you can set the file name filter to show only that pair of files. Next, double click on the files and launch a child Data Compare session comparing those two files. Configure this session's Session Settings, and at the bottom of the Session Setting dialog is a dropdown that says "Use for this view only". Change this to "Use for all files in parent session" (or "Use for these files in parent session"). Close the child Data Compare tab and re-save your parent Folder Compare.

    You can now use this Folder Compare in scripting. The script would perform something like this:
    load parentSession
    expand all
    select all.files
    data-report layout:side-by-side output-to:"c:\bcreport.txt"
    Aaron P Scooter Software


    • #3
      Thanks, Aaron.

      Yes, I'm attempting to generate something like the Data Compare report from a script. And I need to instruct it to ignore certain columns.

      I have BC3 Std, but I would consider upgrading if it made this task easier.



      • #4
        Thanks for the offer, but I cannot think of any BC3 Pro features that would help with this workflow.

        I would suggest starting out in the graphical interface with the saved Folder Compare session, with the saved child session settings for the Data Compare. When you double click on the data files in the saved Folder Compare, if it pops up with the proper defaults (saved as part of the parent), then the script will respect these changes, too.

        I assumed this earlier, but your files/sessions all need to be uniquely configured, correct? If not, you could update the Data Compare's default session settings, and the script would use that without the previous setup or need to open a Folder Compare first. If you are comfortable editing XML, you could also create an automated solution with edits the BCSessions.xml, altering the "default" Data Compare session settings, then calls your BCScript. I'm not sure if this would be an easier solution than the saved Folder Compare, however.
        Aaron P Scooter Software