Metadata-Version: 2.4
Name: modern-csv
Version: 0.5.0
Summary: A zero-dependency CLI tool that audits CSV files for structure, duplication, and formatting errors and generates Markdown reports.
Author-email: Your Name <you@example.com>
License: MIT
Project-URL: Homepage, https://github.com/najm-x/modern-csv
Project-URL: Repository, https://github.com/najm-x/modern-csv
Project-URL: Issues, https://github.com/najm-x/modern-csv/issues
Keywords: csv,lint,audit,data-quality,markdown,cli,validation
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# modern-csv

A zero-dependency Python CLI tool that audits CSV files for structure, encoding, duplication, and data-formatting issues and generates a clean **Markdown (`.md`)** error report.

Use `--tags` to extract only the specific error types or categories you care about, or run `all` checks at once.

## Installation

```bash
pip install modern-csv
```

Or install locally in editable mode during development:

```bash
pip install -e .
```

## Quick Start

```bash
# Audit all 11 checks and write data_errors.md next to data.csv
modern-csv data.csv

# Choose a custom output path (or '-' to print to stdout)
modern-csv data.csv -o reports/audit.md
modern-csv data.csv -o -

# Run specific check tags
modern-csv data.csv --tags encoding,delimiters,nulls

# Run an entire category
modern-csv data.csv --tags structure
modern-csv data.csv --tags formatting

# Specify primary key column(s) (supports composite keys with '+')
modern-csv data.csv --tags duplicate-keys --key id --key email
modern-csv data.csv --tags duplicate-keys --key org_id+user_id

# Short alias & CI mode (exit code 1 if issues are found)
mcsv data.csv --tags all --only-errors --fail-on-error

# List all supported tags
modern-csv --list-tags
```

## Supported Tags

| Category Tag | Check Tag | Issue Detected |
| :--- | :--- | :--- |
| `structure` | `encoding` | **File Encoding Mismatches** — invalid UTF-8 byte sequences, BOM markers, mojibake, `U+FFFD` replacement characters, mixed CRLF/LF line endings |
| `structure` | `delimiters` | **Inconsistent Delimiters** — rows with missing or competing unquoted delimiters (`,`, `;`, `\t`, `\|`) |
| `structure` | `columns` | **Uneven Column Counts** — rows with fewer or more columns than the header row |
| `structure` | `empty-rows` | **Empty Rows & Repeated Headers** — blank/whitespace-only rows and header rows repeated inside data |
| `missing-duplicates` (alias: `duplicates`) | `nulls` | **Null & Missing Values** — empty cells and null placeholders (`NULL`, `N/A`, `NaN`, `None`, `-`, `?`, etc.) with per-column counts |
| `missing-duplicates` | `duplicate-rows` | **Exact Duplicate Rows** — identical rows appearing more than once |
| `missing-duplicates` | `duplicate-keys` | **Duplicate Primary Keys / Unique Identifiers** — duplicate values in `--key` columns or auto-detected ID columns (`id`, `*_id`, `uuid`, `email`, `sku`, etc.) |
| `formatting` (alias: `types`) | `numeric-text` | **Numbers Stored as Text** — currency (`$1,200.50`), comma-grouped numbers, percentages, leading apostrophes (`'123`), and stray text in numeric columns |
| `formatting` | `dates` | **Inconsistent Date Formats** — mixed date formats in the same column (`YYYY-MM-DD`, `MM/DD/YYYY`, `DD/MM/YYYY`, `DD-Mon-YYYY`, etc.) and invalid calendar dates |
| `formatting` | `whitespace-case` | **Leading/Trailing Whitespace & Case Inconsistency** — untrimmed cells/headers and columns with inconsistent casing (e.g., `Active` vs `active`) |
| `formatting` | `hidden-chars` | **Hidden Characters & Embedded Newlines** — zero-width spaces, non-breaking spaces, control characters, and embedded `\n`/`\r` inside quoted fields |

Use `--tags all` (the default) to run every check.

## Python API

```python
from modern_csv import AuditOptions, audit_csv, render_markdown

report = audit_csv("data.csv", AuditOptions(tags=("structure", "nulls"), key_columns=("id",)))
markdown = render_markdown(report, max_samples=50)
print(markdown)
```

## Publishing to PyPI

1. Update `name`, `authors`, and `[project.urls]` in `pyproject.toml`.
2. Build the distribution artifacts:
   ```bash
   python -m pip install build twine
   python -m build
   ```
3. Upload to TestPyPI or PyPI:
   ```bash
   python -m twine upload --repository testpypi dist/*
   python -m twine upload dist/*
   ```

## License

MIT
