Load file from local disk

On this page

When the source file is located on the local disk, GroupDocs.Comparison allows you to load it using the Comparer class constructor by specifying an absolute or relative path. To load the target file located on the local disk, use the add() method. Specify an absolute or relative path as the parameter.

The following code snippet shows how to load files from a local disk:

import groupdocs.comparison as gc

def load_file_from_local_disk(output_file_path, source_file_path, target_file_path):  
    # Initialize comparer with the source document
    with gc.Comparer(source_file_path) as comparer:
        # Add the target document for comparison
        comparer.add(target_file_path)
        
        # Compare the documents and save the result
        comparer.compare(output_file_path)
    
    # Log the success message with the output file path
    print(f"\nDocuments compared successfully.\nCheck output in {output_file_path}.")

On this page