Skip to main content

๐Ÿ” pii-radar

Scan any CSV, JSON, or Parquet file for Personally Identifiable Information โ€” in seconds.

CI Coverage PyPI version Python License: MIT PRs Welcome


Abstract

Data engineers and ML practitioners routinely work with datasets that silently contain Personally Identifiable Information (PII) โ€” emails, phone numbers, SSNs, and credit card numbers โ€” creating compliance risks under GDPR, CCPA, and HIPAA. pii-radar is a lightweight, zero-dependency-ML CLI tool that scans structured data files for PII using high-precision regex patterns, outputting results as rich terminal tables, JSON, or CSV reports. It integrates natively with pre-commit hooks and GitHub Actions to catch PII before it reaches production or version control.


โœจ Features

  • ๐Ÿ”Ž 6 PII types detected โ€” Email, Phone, SSN, Credit Card, IP Address, Date of Birth
  • ๐Ÿ“ 3 file formats โ€” CSV, JSON, Parquet (.parquet, .pq)
  • ๐Ÿ“‚ Folder scanning โ€” Recursively scan entire directories
  • ๐ŸŽจ Beautiful terminal output โ€” Rich tables with confidence scores
  • ๐Ÿค– CI/CD native โ€” --fail-on-detect exits with code 1 for pipeline gates
  • ๐Ÿ”’ Auto-redaction โ€” --redact creates a sanitized copy of your data
  • ๐Ÿ“Š CSV reports โ€” Save all findings to a structured report file
  • โšก Fast โ€” Pure regex, no ML models, no downloads

๐Ÿ“ฆ Installation

pip install pii-radar

Or install from source:

git clone https://github.com/nithin42/pii-radar.git
cd pii-radar
pip install -e ".[dev]"

๐Ÿš€ Quick Start

# Scan a CSV file
pii-radar scan data/customers.csv

# Scan a JSON file
pii-radar scan logs/events.json

# Scan an entire directory
pii-radar scan data/

# Get JSON output (great for scripts)
pii-radar scan data.csv --output json

# Only show high-confidence detections
pii-radar scan data.csv --min-confidence 0.9

# Save a report to CSV
pii-radar scan data.csv --report pii_report.csv

# Create a redacted copy
pii-radar scan data.csv --redact data_clean.csv

# Use in CI/CD โ€” fails build if PII found
pii-radar scan data.csv --fail-on-detect

๐Ÿ—๏ธ Architecture

flowchart TD
    A[CLI โ€” cli.py\nClick commands & flags] --> B{File or Directory?}
    B -->|File| C[Reader โ€” readers.py\nCSV / JSON / Parquet]
    B -->|Directory| D[Directory Walker\nscan_directory]
    D --> C
    C --> E[Cell Stream\ncol, value, row_index]
    E --> F[Detector โ€” detectors.py\nRegex PII Patterns]
    F --> G[PIIMatch objects\ntype, value, confidence]
    G --> H[Scanner โ€” scanner.py\nScanResult aggregation]
    H --> I{Output Mode}
    I -->|table| J[Rich Terminal Table]
    I -->|json| K[JSON stdout]
    I -->|--report| L[CSV Report File]
    I -->|--redact| M[Sanitized CSV Copy]

๐Ÿ“Š Detection Capabilities & Accuracy

PII Type Pattern Confidence Example Detected
EMAIL RFC-compliant regex 98% alice@example.com
SSN USCIS format with invalid-range exclusion 97% 123-45-6789
CREDIT_CARD Luhn-aware prefix matching 92% 4111111111111111
IP_ADDRESS IPv4 full octet range 90% 192.168.1.100
PHONE US/International formats 85% +1 (800) 555-9999
DATE_OF_BIRTH MM/DD/YYYY variants 75% 03/15/1990

Benchmark on 1M cell dataset: ~2.1 seconds (Apple M2), ~4.1 seconds (Intel i5)


๐Ÿ”ง CI/CD Integration

GitHub Actions

- name: Scan for PII before merge
  run: |
    pip install pii-radar
    pii-radar scan data/ --fail-on-detect --min-confidence 0.85

Pre-commit Hook

Add to .pre-commit-config.yaml:

- repo: local
  hooks:
    - id: pii-radar
      name: PII Scanner
      entry: pii-radar scan
      args: [--fail-on-detect, --min-confidence, "0.9"]
      language: python
      types: [csv, json]

๐Ÿ“ Project Structure

pii-radar/
โ”œโ”€โ”€ src/pii_radar/
โ”‚   โ”œโ”€โ”€ cli.py          โ† Click CLI entry point
โ”‚   โ”œโ”€โ”€ scanner.py      โ† Core scan orchestration
โ”‚   โ”œโ”€โ”€ detectors.py    โ† Regex PII detectors
โ”‚   โ”œโ”€โ”€ readers.py      โ† CSV / JSON / Parquet readers
โ”‚   โ””โ”€โ”€ reporter.py     โ† Rich terminal + JSON + CSV output
โ”œโ”€โ”€ tests/
โ”‚   โ”œโ”€โ”€ conftest.py     โ† Shared fixtures
โ”‚   โ”œโ”€โ”€ test_detectors.py
โ”‚   โ”œโ”€โ”€ test_scanner.py
โ”‚   โ””โ”€โ”€ test_cli.py
โ”œโ”€โ”€ examples/
โ”‚   โ”œโ”€โ”€ sample.csv
โ”‚   โ””โ”€โ”€ sample.json
โ”œโ”€โ”€ .github/workflows/  โ† CI/CD pipelines
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ Makefile
โ””โ”€โ”€ README.md

๐Ÿค Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

git clone https://github.com/nithin42/pii-radar.git
cd pii-radar
make install   # installs dev deps + pre-commit hooks
make test      # run tests
make all       # format + lint + typecheck + test

Directory Scanning

Scan all files in a folder recursively:

pii-radar scan data/
```bash

## Roadmap

- [ ] Named entity recognition (NER) mode for detecting names
- [ ] XLSX and SQL dump file support
- [ ] `--anonymize` flag (k-anonymity for numeric columns)
- [ ] HTML report output
- [ ] Config file support (`.pii-radar.yaml`)

---

## ๐Ÿ“„ License

MIT โ€” see [LICENSE](LICENSE).

---

## ๐Ÿ‘ค Author

**Nithin** ยท [github.com/nithin42](https://github.com/nithin42) ยท kumbam.nithingoud@gmail.com

> Part of an elite Data Science & Secure Computing portfolio.
> Focused on data privacy, reproducible ML, and secure systems engineering.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pii_radar-0.3.1.tar.gz (16.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pii_radar-0.3.1-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file pii_radar-0.3.1.tar.gz.

File metadata

  • Download URL: pii_radar-0.3.1.tar.gz
  • Upload date:
  • Size: 16.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pii_radar-0.3.1.tar.gz
Algorithm Hash digest
SHA256 7b26629cc61824356ed628b367b2a0c6a6c5f5c88c11adccc36b52ae688e90ef
MD5 3e005f3e629a60bdf4801b8b9076401e
BLAKE2b-256 c295a4b52cff0c4717277e7e215f2cc77a3d5a8536e160d2e0519ca3ee53eea0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pii_radar-0.3.1.tar.gz:

Publisher: release.yml on nithin42/pii-radar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pii_radar-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: pii_radar-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pii_radar-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8686141798f52d1021d85be6850bf9f2100dd8aefa05ff75860ca4d7926bcdfd
MD5 bae06344d3573d5afcf668ca4f238df2
BLAKE2b-256 0d47705a020e3a98d96f218586eade77514fff677e25fbb2e0c221a5a3d7fdae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pii_radar-0.3.1-py3-none-any.whl:

Publisher: release.yml on nithin42/pii-radar

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page