daff (data diff) is a Python library for comparing tables, producing a summary of their differences, and applying such summaries as patch files. It is optimized for comparing tables that share a common origin, effectively tracking changes between versions of the 'same' table. The library is actively maintained with frequent updates.
pip install daffVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to compare two Python list-of-lists tables using `daff`, generate a diff, and render it as an HTML string for visualization. It uses `PythonTableView` to adapt standard Python data structures for `daff`'s comparison algorithms.
Rename any identifiers named `async` to avoid conflict with the reserved keyword. A common convention is to use `async_` instead.
If encountering unexpected behavior when diffing SQLite databases, review the changes between SQLite versions 3 and 4 or ensure your environment's SQLite library is compatible with `daff`'s expectations.
Avoid using mutable objects as default arguments in your own functions. Instead, use `None` as the default and initialize the mutable object inside the function if it's `None`. Be mindful of this pattern when extending or integrating with `daff`'s API.
Install the daff library using pip: `pip install daff`
Ensure that the input data to daff's table view functions is a list of lists, where each inner list represents a row and contains cell values. Example: `data = [['header1', 'header2'], [1, 2], [3, 4]]`.
Verify that the file paths provided to the `daff` command or functions are correct and that the files exist in the specified locations.