Checks, Reporting & Pandera Integration#
DataSpector’s data-quality engine was originally inspired by seeing an enterprise IT project spend millions of dollars on commercial data-governance and auditing platforms (such as Varonis) to monitor shared file drops and database tables — when a fast, open-source Python engine could enforce richer source, record, and cross-source integrity controls and produce audit-ready Excel reports for free.
Built-in Check Catalog#
Source-Level Checks#
source_exists()— verify file, COBOL pair, or DB table exists.source_fuzzy_find()— wildcard search across files, sheets, or tables.source_has_N_fields()— assert exact column count.source_modified_recently()— assert mtime withindays_agodays.source_modified_on_date()— assert mtime withintoleranceofdate.source_storage_size_roughly()— assert byte size within relative tolerance.source_source_same_fields()— compare column sets across two sources.source_source_identical()— byte-level or shallow file equality.source_source_size_roughly_same()— compare file sizes within tolerance.source_source_roughly_same_number_of_records()— compare row counts across two sources.
Record-Level Checks#
record_validate_schema()(powered by Pandera)
Data-Integrity Design & Pandera Integration#
DataSpector pairs format-agnostic source and streaming record checks with Pandera declarative schemas:
Source, Cross-Source & Streaming Record Controls:
GenericDatainspects file/table metadata (existence, modification timestamps, storage size, column names, row counts) without loading full datasets into memory, and streams records in fixed-size chunks through multi-chunk checks decorated withrequires_all_data().Automated Audit Reporting:
pretty_print_results()renders instant terminal summaries, whilewrite_excel_report()exports color-coded Excel audit workbooks preserving the driver structure with Passed (greenTRUE/ redFALSE), diagnostic Notes, and Exceptions columns.Declarative Pandera Schemas: Pandera is lightweight, pandas-native, zero-infrastructure, supports YAML/JSON schema serialization, and validates each streamed
pandas.DataFramechunk cleanly viarecord_validate_schema()(including schemas auto-generated from COBOL copybooks viato_pandera_schema()).
Using record_validate_schema#
record_validate_schema() accepts:
A
pandera.pandas.DataFrameSchemainstance.A concise Python dictionary (or JSON string) mapping column names to dtypes and checks (
gt,ge,lt,le,in_range,isin,notin,str_length,str_matches,str_startswith,str_endswith,str_contains).A path to a Pandera
.jsonor.yamlschema file.A path to a COBOL
.cblcopybook (automatically converted viato_pandera_schema()).
import pandera.pandas as pa
import dataspector
schema = pa.DataFrameSchema(
{
"host": pa.Column(str, unique=True, checks=pa.Check.str_startswith("srv-app-")),
"domain": pa.Column(int, checks=pa.Check.in_range(1, 10)),
}
)
history = dataspector.run_checks_on_location(
"tests/data/sample_excel.xlsx",
[("record_validate_schema", {"schema": schema})],
)
assert history.all_passed