csvdiff package

Submodules

csvdiff.error module

exception csvdiff.error.FatalError[source]

Bases: exceptions.Exception

csvdiff.error.abort(message=None)[source]

csvdiff.patch module

The the patch format.

exception csvdiff.patch.InvalidPatchError[source]

Bases: exceptions.Exception

csvdiff.patch.apply(diff, recs, strict=True)[source]

Transform the records with the patch. May fail if the records do not match those expected in the patch.

csvdiff.patch.create(from_records, to_records, index_columns, ignore_columns=None)[source]

Diff two sets of records, using the index columns as the primary key for both datasets.

csvdiff.patch.create_indexed(from_indexed, to_indexed, index_columns)[source]
csvdiff.patch.filter_significance(diff, significance)[source]

Prune any changes in the patch which are due to numeric changes less than this level of significance.

csvdiff.patch.is_empty(diff)[source]

Are there any actual differences encoded in the delta?

csvdiff.patch.is_typed(diff)[source]

Are any of the values in the diff typed?

csvdiff.patch.is_valid(diff)[source]

Validate the diff against the schema, returning True if it matches, False otherwise.

csvdiff.patch.load(istream, strict=True)[source]

Deserialize a patch object.

csvdiff.patch.record_diff(lhs, rhs)[source]

Diff an individual row.

csvdiff.patch.save(diff, stream=<open file '<stdout>', mode 'w'>, compact=False)[source]

Serialize a patch object.

csvdiff.patch.validate(diff)[source]

Check the diff against the schema, raising an exception if it doesn’t match.

csvdiff.records module

exception csvdiff.records.InvalidKeyError[source]

Bases: exceptions.Exception

class csvdiff.records.SafeDictReader(istream, sep=None)[source]

A CSV reader that streams records but gives nice errors if lines fail to parse.

fieldnames
csvdiff.records.filter_ignored(sequence, ignore_columns)[source]
csvdiff.records.index(record_seq, index_columns)[source]
csvdiff.records.load(file_or_stream, sep=', ')[source]
csvdiff.records.save(record_seq, fieldnames, ostream)[source]
csvdiff.records.sort(recs)[source]

Module contents

class csvdiff.CSVType[source]

Bases: click.types.ParamType

convert(value, param, ctx)[source]
name = 'csv'
csvdiff.diff_files(from_file, to_file, index_columns, sep=', ', ignored_columns=None)[source]

Diff two CSV files, returning the patch which transforms one into the other.

csvdiff.diff_records(from_records, to_records, index_columns)[source]

Diff two sequences of dictionary records, returning the patch which transforms one into the other.

csvdiff.patch_file(patch_stream, fromcsv_stream, tocsv_stream, strict=True, sep=', ')[source]

Apply the patch to the source CSV file, and save the result to the target file.

csvdiff.patch_records(diff, from_records, strict=True)[source]

Apply the patch to the sequence of records, returning the transformed records.