CsvCompareDiffs

class csvcomparer.CsvCompareDiffs(row_key: List[str], rows_added: Dict[str, Dict[str, Any]], rows_removed: Dict[str, Dict[str, Any]], rows_changed: Dict[str, List[Dict[str, Any]]], cols_added: List[str], cols_removed: List[str])

Convenience dataclass for CsvCompare.

Provides an accumulation all of the difference types:

  • Rows added to the right file (rows_added)

  • Rows removed from the left file (rows_removed)

  • Rows with deltas between files (rows_changed)

  • Columns added to the right file (cols_added)

  • Columns removed from the left file (cols_removed)

Additionally provides:

  • row_key as reference to CsvCompare’s index column(s)

  • to_json() for converting diffs to JSON format

to_dict()

Convenience function to use instead of dataclasses.asdict().

Returns:

dict: CsvCompareDiffs converted to dictionary.

to_json()

Convert CsvCompareDiffs to JSON format.

Returns:

str: Serialization of Python JSON object.