No announcement yet.

Compare 2 CSV files, output a new file containing differences

  • Filter
  • Time
  • Show
Clear All
new posts

  • Compare 2 CSV files, output a new file containing differences

    Hi there,

    Apologies if this has been posted before, I did search for several minutes but did not find any examples.

    I have 2 data files (CSV) which I would like to compare programmatically on a nightly basis. Each line in these files consist of a data row which we import into a database. Is it possible to use Beyond Compare to;
    1. Compare the 2 files
    2. Output any differences between the 2 into a new CSV file (the entire line needs to be copied across into the new file regardless of what file the difference occurred in)

    this allows us to only import data that has changed since the previous nights import.

    Any example scripts would be appreciated.

  • #2

    Unfortunately, we do not have an automated solution for copying specific CSV text data into a new CSV file. We can copy entire files from the left to the right, or vice versa, or we can output text reports in plain text or html formats. These reports can be parsed for information and can contain just the different lines.

    You can generate these reports using the graphical interface. If one of them is suitable for your needs, then we can come up with the script that generates the same report automatically.

    Do you compare your CSV files using our Text Compare or Data Compare session type? This determines the types of reports available to you. You can try out both session types, then generate reports using the Session menu -> Text/Data Comparison Report. These reports can be configured to show only the different lines.

    Do any of these reports meet your needs?

    If you do not have the software yet, our trial is fully featured and this can be fully tested before purchase:
    Aaron P Scooter Software


    • #3 to generate Data Compare Info w/o GUI?


      A similar question - is it possible to use the tool to compare two csv files, and generate the Data Compare Info / Data Compare Report, without launching the GUI? This could let us use this tool in an integration test.

      Many thanks



      • #4

        You can use BC Scripting.

        It launches BC3 in scripting mode, which is a small gui window (which can be suppressed with /silent, but I *strongly* recommend running with the GUI for feedback). Scripting will run a series of commands which are not undo-able actions, so please test on test folders, and if you suppress the gui there will be no feedback or error messages as to what actions were taken.

        Scripting reference is available in the Help file -> Using Beyond Compare -> Automating with script. The command line is bcompare.exe "@c:\script.txt" "c:\file1.csv" "c:\file2.csv"
        where script.txt contains the script commands, such as:
        data-compare layout:side-by-side output-to:"c:\bcreport.html" output-options:html-color "%1" "%2"
        Aaron P Scooter Software


        • #5
          I am able to get "Data Compare Report" report but unable to figure out how to get "Data Compare Info" report using scripting which basically provides something like below. I want to run some % analytics based on below data.

          413 same row(s)
          5 important left orphan row(s)
          4 important right orphan row(s)
          1 important difference row(s)


          • #6
            This is a bit urgent. Help is greatly appreciated.


            • #7

              BC2's Data Viewer does not have as many report options. BC3 and BC4 have added more report types, including data-report layout:summary. The trial is available if you would like to test to make sure this report type meets your needs. You can install BC4's trial without removing or altering BC2:
              Aaron P Scooter Software


              • #8
                Thanks Aaron! I do have licensed version of BC3. Is there as way I can combine data-report layout:summary AND data-report layout:side-by-side in one file with just one run. Currently I have to run the same report comparison twice to get one summary and one side-by-side compare report. Please understand that file sizes that I am comparing ate around 40 MB each.


                • #9

                  Sorry, there isn't a way to get both result reports in a single report run. You would need to run the report command twice to generate both reports. HTML reports can be difficult to append together as HTML code, but two text reports could be joined after they are generated. It may be easier to leave the two reports separate but with related, easy to sort names.
                  Aaron P Scooter Software


                  • #10
                    Thanks! I suggest you should have this feature. Just quick thing. 2 HTML files can be merged easily. Take any 2 HTML files, copy and paste below lines in a batch file (changing the file name as you desire) and run the batch file. Even I got to know this today from a friend.

                    type FirstHTML.html > CombinedReport.html
                    type SecondHTML.html >> CombinedReport.html
                    Last edited by AjitPandey; 22-Oct-2015, 01:08 PM.