Metadata-Version: 2.4
Name: minimindslab-csv-headers-align
Version: 0.1.0
Summary: Normalize CSV header order to match a target header list, reordering present columns and optionally identifying missing or extra columns.
Author: MiniMindsLab
License: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# MiniMindsLab CSV Headers Align

Normalize CSV header order to match a target header list, reordering present columns and optionally identifying missing or extra columns.

## Install

```bash
pip install minimindslab-csv-headers-align
```

## Usage

```python
from minimindslab_csv_headers_align import align_headers

header = ["id", "name", "email", "legacy"]
target = ["name", "email", "id", "country"]

result = align_headers(header, target)

print(result.aligned)  # ['name', 'email', 'id']
print(result.missing)  # ['country']
print(result.extra)    # ['legacy']
```

## API

- `align_headers(header_row, target_headers, *, validate=False)`
  - Returns `AlignmentResult(aligned, missing, extra)`.
  - `aligned`: present columns in target order.
  - `missing`: target headers not present in input.
  - `extra`: input headers not present in target.
  - If `validate=True`, raises `ValueError` when missing headers exist.

## Notes

- Pure Python standard library only.
- Inputs are normalized to strings using `str(value)` for non-`None` values, and `""` for `None`.
- Duplicate values in `target_headers` are deduplicated by first appearance for deterministic behavior.
