Scan any CSV, JSON, or Parquet file for Personally Identifiable Information β in seconds.
Data engineers and ML practitioners routinely work with datasets that silently contain Personally Identifiable Information (PII) β emails, phone numbers, SSNs, credit card numbers, and IP addresses β 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 patterns, Luhn Mod-10 verification, and contextual heuristics, 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.
pii-radar provides streaming PII redaction components for Microsoft Azure Storage and Azure Event Hubs:
from pii_radar.integrations import AzureBlobStreamRedactor
# Scans CSV/JSON blobs in Azure Blob Storage and uploads redacted sanitized copies
redactor = AzureBlobStreamRedactor(
connection_string="DefaultEndpointsProtocol=https;...",
container_name="customer-data"
)
total_found, counts = redactor.redact_blob("raw_customers.csv", output_blob_name="sanitized_customers.csv")
print(f"Redacted {total_found} PII occurrences in Azure Blob Storage.")from pii_radar.integrations import AzureEventHubHandler
# Redacts sensitive PII in real-time telemetry streaming event batches
handler = AzureEventHubHandler(
connection_string="Endpoint=sb://...",
eventhub_name="telemetry-hub"
)
redacted_events = handler.process_event_batch(raw_event_messages)- β‘ Azure Blob Storage Stream Redactor β Real-time PII scanning & masking for CSV/JSON files in Azure Storage containers (
AzureBlobStreamRedactor) - π‘ Azure Event Hubs Integration β Low-latency PII redaction pipeline for streaming telemetry in Azure Event Hubs (
AzureEventHubHandler) - π 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-detectexits with code 1 for pipeline gates - β‘ Row sampling β
--sample 1000limit for rapid audit sampling on massive files - π Auto-redaction β
--redactcreates a sanitized copy of your data - π CSV reports β Save all findings to a structured report file
- β‘ Fast β Pure regex + algorithmic validation, no heavy ML models
# Base installation (Lightweight)
pip install pii-radar
# With Azure Blob Storage & Azure Event Hubs support
pip install "pii-radar[azure]"
# With Parquet support
pip install "pii-radar[parquet]"
# Everything (Azure Blob/EventHubs + Parquet)
pip install "pii-radar[all]"Or install from source:
git clone https://github.com/nithin42/pii-radar.git
cd pii-radar
pip install -e ".[dev]"# Scan a CSV file
pii-radar scan data/customers.csv
# Fast sampling (scan only first 1,000 rows)
pii-radar scan data/large_file.csv --sample 1000
# 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-detectCLI Interface (cli.py)
β
βββΊ scan_file / scan_directory (scanner.py)
β β
β βββΊ File Readers (readers.py) β CSV / JSON / Parquet Cell Stream
β β
β βββΊ Heuristic Engine (detectors.py)
β ββ Email (RFC-compliant regex)
β ββ SSN (Format + Range Rejection)
β ββ Credit Card (Luhn Mod-10 Checksum)
β ββ Phone (Word-bounded pattern)
β ββ IP Address (IPv4 0-255 Octet Validation)
β ββ Date of Birth (Column-Name Heuristic + Format)
β
βββΊ Reporting Layer (reporter.py)
ββ Rich Terminal Panel & Table
ββ JSON Pipeline Stream
ββ CSV Compliance Report
| PII Type | Verification Strategy | Accuracy / False Positive Defense |
|---|---|---|
| RFC-compliant regex | 99% β Word boundary enforced | |
| SSN | Format + Area exclusion | 98% β Rejects invalid 000, 666, 900+ ranges |
| CREDIT_CARD | Luhn Mod-10 Algorithm | 99% β Eliminates random 16-digit number false positives |
| IP_ADDRESS | IPv4 + Octet range check | 95% β Rejects 999.x.x.x and version strings |
| PHONE | US/International regex | 92% β Enforces strict \b word boundaries |
| DATE_OF_BIRTH | Format + Column Heuristics | 95% β Contextual matching (dob, birth, bday) |
Run the reproducible benchmark script locally:
python examples/benchmark.py- Dataset: 10,000 rows x 7 columns (70,000 cells)
- Throughput: ~45,000β60,000 cells/second
- Memory Overhead: Minimal (generator-based cell streaming)
- name: Scan for PII before merge
run: |
pip install pii-radar
pii-radar scan data/ --fail-on-detect --min-confidence 0.85Add 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]pii-radar/
βββ src/pii_radar/
β βββ cli.py β Click CLI entry point (--sample, --fail-on-detect)
β βββ scanner.py β Core scan orchestration with row limits
β βββ detectors.py β Luhn + IPv4 range + DOB heuristics engine
β βββ readers.py β CSV / JSON / Parquet readers
β βββ reporter.py β Rich terminal + JSON + CSV output
βββ tests/
β βββ conftest.py β Shared fixtures
β βββ test_detectors.py
β βββ test_negative_cases.py β False positive & Luhn unit tests
β βββ test_scanner.py
β βββ test_cli.py
βββ examples/
β βββ sample.csv
β βββ sample.json
β βββ benchmark.py β Performance benchmarking tool
βββ .github/workflows/ β CI/CD matrix (Ubuntu + Windows)
βββ pyproject.toml
βββ Makefile
βββ README.md
MIT β see LICENSE.
Nithin Β· 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.


