Skip to main content

Data Quality Detective

tests PyPI Python 3.10+ MIT License

A lightweight Python CLI for the first pass through a new dataset.

dqdetect profiles CSV, Excel, and optional database-table input, flags common data-quality issues, and writes reports that can be reviewed by a person or consumed by another tool. It deliberately does not modify the source data.

Data Quality Detective demo

Install

pip install dqdetect

Profile a file:

dqdetect path/to/file.csv

By default, dqdetect writes Markdown and HTML reports to the reports/ folder.

What it checks

  • dataset shape and column types
  • duplicate rows
  • missing values by column
  • constant columns
  • mixed numeric/text values
  • invalid values in date-like columns
  • IQR-based numeric outliers
  • optional expected-column and type rules from a JSON schema file

The current scope is intentionally diagnostic: dqdetect tells you what deserves review, but it does not automatically delete, impute, coerce, or replace source values.

Report formats

Generate one format:

dqdetect data.csv --format md
dqdetect data.csv --format html
dqdetect data.csv --format json

Generate all three:

dqdetect data.csv --format all

JSON output includes the dataset summary, analysis settings, per-column profile, optional schema/comparison results, and recommendations.

Excel

Select an Excel sheet by name or zero-based index:

dqdetect workbook.xlsx --sheet Orders
dqdetect workbook.xlsx --sheet 0

Configurable outlier thresholds

The default IQR rule uses a 1.5 multiplier and requires at least 4 non-missing values.

dqdetect data.csv --iqr-multiplier 2.0
dqdetect data.csv --min-outlier-sample-size 10

These options change how potential numeric outliers are screened; they do not remove any values.

Schema rules

Use a small JSON file when a dataset is expected to contain specific columns or broad data types.

{
  "required_columns": ["order_id", "order_date", "amount"],
  "column_types": {
    "order_id": "numeric",
    "order_date": "date",
    "amount": "numeric"
  },
  "allow_extra_columns": true
}

Supported schema types are:

  • numeric
  • text
  • date
  • boolean

Run the schema check with:

dqdetect data.csv --schema schema.json --format all

See examples/messy_orders_schema.json for a complete example.

Compare two versions of a dataset

Compare the current file with an earlier CSV or Excel file:

dqdetect current.csv --compare previous.csv --format all

The comparison reports:

  • row and column count changes
  • duplicate-row changes
  • added and removed columns
  • data-type changes
  • missing-value count changes

For Excel comparison files, use --compare-sheet when needed.

Database tables

Database support is optional so the base package stays small.

Install the database extra:

pip install "dqdetect[database]"

For PostgreSQL, prefer putting the connection URL in an environment variable instead of typing credentials directly into shell history:

export DQDETECT_DATABASE_URL="postgresql+psycopg://user:password@host:5432/database"
dqdetect --table orders --db-schema public --format html

A SQLAlchemy URL can also be passed with --database-url.

The database loader uses SQLAlchemy table reflection rather than constructing a raw SQL string from the table name.

Use dqdetect in CI

--fail-on-issues returns a non-zero exit status when dqdetect finds a data-quality or schema issue.

dqdetect data.csv --schema schema.json --fail-on-issues

The repository also includes a reusable composite GitHub Action:

- uses: actions/checkout@v5

- uses: actions/setup-python@v6
  with:
    python-version: "3.11"

- uses: Shahedr/data-quality-detective@v1.0.0
  with:
    file: data/orders.csv
    format: json
    output: dqdetect-reports
    schema: data/schema.json
    fail-on-issues: "true"

- uses: actions/upload-artifact@v4
  if: always()
  with:
    name: dqdetect-report
    path: dqdetect-reports/

This makes it possible to use the same checks locally and in a repository workflow.

Example

For the sample dataset in this repository:

Data Quality Detective
Source: messy_orders.csv

Rows: 12
Columns: 8
Duplicate rows: 1

Issues found
- 2 columns contain missing values
- 1 column contains mixed numeric/text values
- 1 date-like column contains invalid values
- 2 numeric columns contain potential IQR outliers

See:

Why the tool does not auto-clean

A suspicious value is not automatically a wrong value.

A freight field containing text such as Included may carry business meaning. An extreme order value may be a legitimate large transaction. A missing value may need imputation, exclusion, preservation, or a source-system correction depending on context.

dqdetect therefore follows one rule throughout the project:

detect → report → review → decide

Project structure

data-quality-detective/
├── action.yml
├── dqdetect/
│   ├── __init__.py
│   ├── __main__.py
│   ├── checks.py
│   ├── cli.py
│   ├── compare.py
│   ├── database.py
│   ├── io.py
│   ├── profiler.py
│   ├── report.py
│   ├── schema.py
│   └── types.py
├── examples/
├── tests/
├── .github/workflows/
│   ├── tests.yml
│   └── publish-to-pypi.yml
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
└── pyproject.toml

The package separates command-line handling, input loading, profiling, detection rules, schema validation, comparison, database access, and report generation so each part can be tested independently.

Testing

The automated test suite covers the CLI, file loading, profiling rules, reporting, schema validation, dataset comparison, database loading, and deterministic IQR behavior.

GitHub Actions runs the tests across Python 3.10–3.13, performs a real PostgreSQL integration check, smoke-tests the reusable GitHub Action, builds the package, and validates distribution metadata.

Run the suite locally with:

git clone https://github.com/Shahedr/data-quality-detective.git
cd data-quality-detective
pip install -e ".[dev,database]"
pytest

Project status

v1.0.0 completes the planned feature scope for Data Quality Detective.

The project is feature-complete for its current purpose: a lightweight first-pass profiler. Future changes are expected to be maintenance, bug fixes, compatibility updates, or narrowly scoped improvements rather than continued expansion into a full validation framework.

License

MIT

Metadata

Release files for dqdetect 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dqdetect 1.0.0
File Size Uploaded Provenance Actions
dqdetect-1.0.0.tar.gz 22.8 kB With provenance Details for dqdetect-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dqdetect 1.0.0
File Interpreter ABI Platform Actions
dqdetect-1.0.0-py3-none-any.whl Python 3 none any Details for dqdetect-1.0.0-py3-none-any.whl

Total release size: 40.9 kB

Release files / dqdetect-1.0.0.tar.gz

Download URL dqdetect-1.0.0.tar.gz
Size 22.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d12b191ea6bf49eb35a5256fcaa9d0cd159bd6adae509aa18f28da8e7a3a6ff6
BLAKE2b-256 checksum
How to use checksums
e006fc166ce807dd99db06afee4ec024736d58ccdbba63e9247adf43a8701923
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Release files / dqdetect-1.0.0-py3-none-any.whl

Download URL dqdetect-1.0.0-py3-none-any.whl
Size 18.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
24cb5e71e334ed9b8f0f0e4322caab0e37c2959c057f579d846b8decb06a8e86
BLAKE2b-256 checksum
How to use checksums
631a1966d140c2e4cf448bbb4917318f972605b2d33ac80f87a58f039ec40714
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

Security for dqdetect 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for dqdetect-1.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page