Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2018
    Location
    U.S.
    Posts
    2

    Default Scripting data-report for multiple CSV files

    Hello,

    I've been doing a lot of digging around on the forums and I have not found conclusive answers for my questions. If someone would be so kind to answer them, that would be great!

    First a description of what my end goals are:

    I want to create a script to automatically generate side-by-side difference reports for roughly 100 csv files. I would like to dump 50 of the files in one folder and dump the remaining 50 files in a second folder. Read the folders in the script and loop through each file in each folder creating difference reports for them, ending with a total of 50 difference reports.

    Preferably I would like to create an html-color report and save it as an MS Excel file (*.xlsx) - but from what I was reading this is not doable in BC4. So I will need to save the difference reports as *.html files and then open each one in Excel and perform a Save-As *.xlsx.

    Below is my command line to activate the script:
    Code:
    BCompare.exe @"C:\Users\probat\Desktop\Compare_Sample\Sample_Script.txt"
    Below is the code for the script:
    Code:
    # Generating a report of differences
    # This script generates a report of only differences.
    #_____________________________________________________
    
    # Set up basic comparison features.
    criteria rules-based
    
    # Filter out log files.
    filter "*.txt; *.mdb"
    
    # Load first comparison.
    load "C:\Users\probat\Desktop\Compare_Sample\First_Folder" "C:\Users\probat\Desktop\Compare_Sample\Second_Folder"
    
    # Compare files with timestamp differences.
    select all.diff.files
    
    # Generate a report of the differences.
    data-report layout:side-by-side &
    options:ignore-unimportant,line-numbers &
    output-to:"C:\Users\probat\Desktop\Compare_Sample\Diff_Report.html" &
    output-options:html-color
    Question 1: How can I automatically generate a name for each difference report. Currently I have "Diff_Report.html" as the name but this will obviously overwrite every single difference report file and I will be left with one difference report at the end, rather than 50 difference reports. I would like to use a part of the name from the .csv files so they can easily be recognized if that is possible?

    Question 2: Is it possible to set up rules in the script for the data-report, for example enable "unsorted alignment "?

    Question 3: Is it possible save the difference report as a MS Excel file? (From material I've read I don't think it is)?

  2. #2
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    11,750

    Default

    Hello,

    When selecting multiple files and generating a report, this will generate a single report file. To generate individual reports, you'll need to:
    a) pass in 2 files as parameters and generate a single report.
    b) load folders, and generate a Folder-report with the include-file-links option.

    For a), you can use:
    bcompare.exe "@c:\bcscript.txt" "c:\users\probat\desktop\compare_sample\first_fold er\file1.txt" "C:\Users\probat\Desktop\Compare_Sample\Second_Fol der\file1.txt" "C:\Users\probat\Desktop\Compare_Sample\Diff_Repor t_file1.html"

    where bcscript.txt is then:
    data-report layout:side-by-side &
    options:ignore-unimportant,line-numbers &
    output-to:"$3" &
    output-options:html-color "$1" "$2"

    2) Not as a scripted option. You can set the default settings of the Table Compare session in the graphical interface, which is then used as part of the script. You could also edit the BCSessions.xml before calling to the script, to edit the default session settings.

    3) No, the output is either to printer, .txt, or .html. Excel supports opening .html files into the main interface, which can then be Saved As... .XLSX.
    Aaron P Scooter Software

  3. #3
    Join Date
    Jul 2018
    Location
    U.S.
    Posts
    2

    Default

    Thanks for the info Aaron. A quick follow up question regarding the following you provided:

    bcompare.exe "@c:\bcscript.txt" "c:\users\probat\desktop\compare_sample\first_ fold er\file1.txt" "C:\Users\probat\Desktop\Compare_Sample\Second _Fol der\file1.txt" "C:\Users\probat\Desktop\Compare_Sample\Diff_R epor t_file1.html"

    I have 100 files I am going to be comparing. Is there a way that I can give some parameter instead of having to verbatim include the name of the files to be diff'd? For example:

    bcompare.exe "@c:\bcscript.txt" "c:\users\probat\desktop\compare_sample\first_ fold er\<<<Some Parameter to Fetch 1st File>>>" "C:\Users\probat\Desktop\Compare_Sample\Second _Fol der\<<<Some Parameter to Fetch 2nd File>>> "C:\Users\probat\Desktop\Compare_Sample\Diff_R epor t_file1.html"

    This would be more efficient.

    Thanks

  4. #4
    Join Date
    Oct 2007
    Location
    Madison, WI
    Posts
    4,658

    Default

    If you haven't tried it yet, using folder-report with include-file-links as Aaron described earlier might do what you want. It creates a single parent folder compare report as HTML listing names of files, when you click on links in that report it will open a separate report for each pair of files.
    Chris K Scooter Software

Posting Permissions

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