Registry / data / daff

daff

JSON →
library1.4.2pypypi✓ verified 52d ago

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.

data
pip install daff
Install & Compatibility
Where this runs
tested against v1.4.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.925 runs
installs and imports cleanly · install 0.0s · import 0.062s · 18.5MB
glibc
py 3.103.925 runs
installs and imports cleanly · install 1.7s · import 0.058s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

daff
import daff

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.

import daff data1 = [ ['Country', 'Capital'], ['Ireland', 'Dublin'], ['France', 'Paris'], ['Spain', 'Barcelona'] ] data2 = [ ['Country', 'Code', 'Capital'], ['Ireland', 'ie', 'Dublin'], ['France', 'fr', 'Paris'], ['Spain', 'es', 'Madrid'], ['Germany', 'de', 'Berlin'] ] # Create table views for the data table1 = daff.PythonTableView(data1) table2 = daff.PythonTableView(data2) # Compare tables to get alignment information alignment = daff.Coopy.compareTables(table1, table2).align() # Prepare an empty table to hold the diff results data_diff = [] table_diff = daff.PythonTableView(data_diff) flags = daff.CompareFlags() highlighter = daff.TableDiff(alignment, flags) highlighter.hilite(table_diff) # Render the diff to HTML for visualization diff_render = daff.DiffRender() diff_render.usePrettyArrows(False) # Optional: control arrow style diff_render.render(table_diff) table_diff_html = diff_render.html() print("Original Table 1:", data1) print("Modified Table 2:", data2) print("\nHTML Diff:\n", table_diff_html)
daff --version
Debug
Known issues
breakingThe keyword `async` became a reserved keyword in Python 3.7. If you were using `async` as a variable name, function parameter, or identifier in your code that interacts with `daff`, it will now cause a `SyntaxError` in Python 3.7 and newer.
fix
Rename any identifiers named `async` to avoid conflict with the reserved keyword. A common convention is to use `async_` instead.
affects: >=3.7.0
gotchaThe optional `sqlite3` dependency was updated from version 3 to 4 in `daff` v1.3.37. While `sqlite3` is a built-in Python module, this update might subtly affect behavior or introduce incompatibilities if your application relies on specific, advanced features or versions of SQLite that `daff` interacts with, especially when using `--input-format sqlite`.
fix
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.
affects: >=1.3.37
gotchaLike many Python libraries, `daff`'s API might expose functions or methods where mutable objects (e.g., lists, dictionaries) are used as default arguments. Using mutable defaults can lead to unexpected side effects across multiple function calls, as the default object is created only once when the function is defined.
fix
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.
affects: <all>
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'daff'
The 'daff' library is not installed in the Python environment where the code is being run.
fix
Install the daff library using pip: `pip install daff`
TypeError: 'int' object is not iterable
This typically occurs when passing incorrectly structured data (e.g., a flat list of numbers instead of a list of lists/rows) to `daff.PythonTableView` or similar table construction methods, as the library expects an iterable of iterables for rows and cells.
fix
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]]`.
FileNotFoundError: [Errno 2] No such file or directory
When using the `daff` command-line tool or its Python functions that read from files (e.g., `daff.diff_tables_from_csv`), this error occurs if the specified input CSV or other data files do not exist at the given path.
fix
Verify that the file paths provided to the `daff` command or functions are correct and that the files exist in the specified locations.
Upgrade
Version history
1.4.2latest on PyPI
Audit
Dependencies
sqlite3optionalUsed for diffing SQLite databases; updated in v1.3.37. It's an optional dependency handled internally.
Agent activity
18 hits · last 30 days
node
4
seranking-bot
4
Amazon
2
ahrefsbot
2
amazonbot
1
googlebot
1
Resources