Skip to main content

DataSpector

DataSpector is a format-agnostic Python toolkit for converting legacy fixed-width and compressed mainframe/COBOL files into modern human-readable formats and enforcing data-integrity checks across heterogeneous data sources (COBOL, CSV, fixed-width text, Excel, Parquet, JSON/JSONL, SQLite, and ODBC databases).

Highlights

  • Convert mainframe & fixed-width COBOL files effortlessly (coboller): turn opaque EBCDIC, fixed-width, and binary-compressed files (COMP-3 packed decimal, COMP/COMP-5/COMP-X, COMP-6, COMP-1/COMP-2 IEEE & IBM HFP, BINARY-*, FLOAT-*, PIC U UTF-8, PIC G DBCS, PIC 1 bitfields, OCCURS, REDEFINES) directly into CSV, TSV, JSON/JSONL, Excel, Parquet, or pandas DataFrames — via CLI or Python.
  • Format-agnostic GenericData abstraction: query existence, columns, modification timestamps, storage size, table/sheet lists, and stream records uniformly as pandas.DataFrame chunks across all supported formats.
  • Pandera schema integration: run declarative pandera.DataFrameSchema validations on any format via record_validate_schema, or auto-generate a Pandera schema directly from a COBOL copybook with CopyBook.to_pandera_schema().
  • Excel driver & reporting: configure batch integrity checks in an Excel workbook, execute sequentially or in parallel, and export color-coded Excel reports.

Installation

DataSpector uses uv for dependency and environment management:

uv sync --dev

Optional extras:

uv sync --extra odbc   # pyodbc support for SQL Server / MS Access
uv sync --extra docs   # Sphinx + PyData theme documentation dependencies

Converting Fixed-Width & Compressed COBOL Files (coboller)

Mainframe extracts are often unreadable binary/EBCDIC blobs packed with COMP-3, COMP, and floating-point fields:

b'\xd5\xc1\xf1\xf0\xf0\xf0\xf0\xf0\xf1\xf7@@\xc1\xf2\xf0\xf2\xf4\xf0\xf1\xf1\xf5\xf0\xf0\xf1\xf2\xf5\xf5\xc0\x00$\x00\x0b^(=.\x14{?\xf0'

One-Line CLI Inspection & Conversion

Both coboller and dataspector CLIs are powered by jsonargparse from typed dataclasses in dataspector.settings (supporting --config config.yaml files as well as CLI flags):

# Inspect field layout, byte offsets, PIC clauses, and storage types
uv run coboller inspect tests/data/sample_cobol_mainframe.cbl --omit_filler true

# Preview decoded records directly in the terminal
uv run coboller convert tests/data/sample_cobol_mainframe.cbl tests/data/sample_cobol_mainframe.dat --encoding cp500

# Convert binary EBCDIC/COMP-3 data directly to human-readable CSV, JSONL, JSON, or Excel
uv run coboller convert tests/data/sample_cobol_mainframe.cbl tests/data/sample_cobol_mainframe.dat \
    --encoding cp500 --output accounts.csv

Interactive Python Walkthrough

>>> from dataspector.coboller import Copybook
>>> cbl = Copybook("tests/data/sample_cobol_mainframe.cbl")
>>> cbl.record_length
67

# 1. Inspect the decoded byte layout interactively
>>> cbl.summary(include_filler=False)[["name", "pic", "usage", "offset", "byte_length"]].head(6)
               name      pic   usage  offset  byte_length
0       ACCT-REGION       XX DISPLAY       0            2
1       ACCT-NUMBER     X(7) DISPLAY       2            7
2  ACCT-CHECK-DIGIT        X DISPLAY       9            1
3       ACCT-STATUS        X DISPLAY      12            1
4     ACCT-EFF-DATE     9(8) DISPLAY      13            8
5   ACCT-ADJUSTMENT S9(5)V99 DISPLAY      21            7

# 2. Preview decoded mainframe records as a clean pandas DataFrame
>>> df = cbl.to_dataframe(
...     "tests/data/sample_cobol_mainframe.dat",
...     encoding="cp500",
...     include_filler=False,
...     nrows=5,
... )
>>> df[["ACCT-REGION", "ACCT-NUMBER", "ACCT-STATUS", "ACCT-ADJUSTMENT", "ACCT-BALANCE"]]
  ACCT-REGION ACCT-NUMBER ACCT-STATUS  ACCT-ADJUSTMENT  ACCT-BALANCE
0          NA     1000001           A           125.50     250000.00
1          EU     1000002           A           -42.75     -15000.50
2          AP     1000003           C             0.00          0.00
3          NA     1000004           A          9999.99    1234567.89

# 3. Stream-convert to human-readable CSV, JSONL, JSON, Excel, or Parquet
>>> cbl.convert("tests/data/sample_cobol_mainframe.dat", "accounts.csv", encoding="cp500")
PosixPath('accounts.csv')
>>> cbl.convert("tests/data/sample_cobol_mainframe.dat", "accounts.jsonl", encoding="cp500")
PosixPath('accounts.jsonl')

# 4. Auto-generate a Pandera schema from the copybook and validate the decoded data
>>> schema = cbl.to_pandera_schema(include_filler=False, enforce_conditions=True)
>>> _ = schema.validate(df)

Format-Agnostic Data-Integrity Checks

Python API

from pathlib import Path
import dataspector

results = dataspector.run_checks_on_location(
    Path("tests/data/sample_csv.csv"),
    [
        ("source_exists", {}),
        ("source_has_N_fields", {"n_fields": 5}),
        ("record_count", {"nrows": 31}),
        ("record_field_numeric_value_between", {"field": "Cost [CAD]", "constraint": (0, 200000)}),
    ],
)
assert results.all_passed

Batch Checks via Excel Driver CLI

uv run dataspector --driver test_driver.xlsx --output report.xlsx
uv run dataspector --config run.yaml

Key options (from DataSpectorSettings):

  • --driver: path to the Excel driver workbook (Location Details and Checks to Run sheets).
  • --output: path to write the formatted Excel report (auto-versioned unless --overwrite true).
  • --use_multiprocess true: run location checks in parallel worker processes.
  • --log_level: Loguru verbosity (ERROR, WARNING, INFO, DEBUG, TRACE).
  • --config: optional YAML/JSON configuration file.

Development

# Run tests with coverage
uv run pytest

# Lint & format check
uv run ruff check src tests

# Static type checking
uv run ty check src tests

# Build Sphinx HTML documentation (PyData theme)
uv run sphinx-build -b html docs/source docs/build/html

Metadata

Release files for dataspector 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 dataspector 1.0.0
File Size Uploaded Provenance Actions
dataspector-1.0.0.tar.gz 253.6 kB With provenance Details for dataspector-1.0.0.tar.gz

Built distribution (wheel)

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

Total release size: 312.7 kB

Release files / dataspector-1.0.0.tar.gz

Download URL dataspector-1.0.0.tar.gz
Size 253.6 kB
Tags Source
SHA-256 checksum
How to use checksums
81ff616fafc2d112d7a305c999eaca41ac3a8e882dbc5c2bf0486f4d2523a68f
BLAKE2b-256 checksum
How to use checksums
6c008a0d9fa66b0931cd2d6b174fea8506a9035c06ec5bb90d199828b46e9684
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 20, 2026.

Transparency log

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

Download URL dataspector-1.0.0-py3-none-any.whl
Size 59.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd959fd7b19fa561b806573fe0516f67fc13c42c85441965264c6e85dff26bf4
BLAKE2b-256 checksum
How to use checksums
dec1a029b38c7f69304c172945b5ec6ed14b2eb38de9cbd663807c439667fc31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 20, 2026.

Transparency log

Security for dataspector 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 dataspector-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 Nov 20, 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.

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