๐ pii-radar
Scan any CSV, JSON, or Parquet file for Personally Identifiable Information โ in seconds.
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-detectexits with code 1 for pipeline gates - ๐ Auto-redaction โ
--redactcreates 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 |
|---|---|---|---|
| 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b26629cc61824356ed628b367b2a0c6a6c5f5c88c11adccc36b52ae688e90ef
|
|
| MD5 |
3e005f3e629a60bdf4801b8b9076401e
|
|
| BLAKE2b-256 |
c295a4b52cff0c4717277e7e215f2cc77a3d5a8536e160d2e0519ca3ee53eea0
|
Provenance
The following attestation bundles were made for pii_radar-0.3.1.tar.gz:
Publisher:
release.yml on nithin42/pii-radar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pii_radar-0.3.1.tar.gz -
Subject digest:
7b26629cc61824356ed628b367b2a0c6a6c5f5c88c11adccc36b52ae688e90ef - Sigstore transparency entry: 2298455904
- Sigstore integration time:
-
Permalink:
nithin42/pii-radar@a6a2e609a7d6dd7451bfb3dc4e43d656af49c9f7 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/nithin42
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a6a2e609a7d6dd7451bfb3dc4e43d656af49c9f7 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8686141798f52d1021d85be6850bf9f2100dd8aefa05ff75860ca4d7926bcdfd
|
|
| MD5 |
bae06344d3573d5afcf668ca4f238df2
|
|
| BLAKE2b-256 |
0d47705a020e3a98d96f218586eade77514fff677e25fbb2e0c221a5a3d7fdae
|
Provenance
The following attestation bundles were made for pii_radar-0.3.1-py3-none-any.whl:
Publisher:
release.yml on nithin42/pii-radar
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pii_radar-0.3.1-py3-none-any.whl -
Subject digest:
8686141798f52d1021d85be6850bf9f2100dd8aefa05ff75860ca4d7926bcdfd - Sigstore transparency entry: 2298455920
- Sigstore integration time:
-
Permalink:
nithin42/pii-radar@a6a2e609a7d6dd7451bfb3dc4e43d656af49c9f7 -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/nithin42
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a6a2e609a7d6dd7451bfb3dc4e43d656af49c9f7 -
Trigger Event:
push
-
Statement type: