Metadata-Version: 2.4
Name: csv-conflict
Version: 0.1.0
Summary: Fix a CSV file broken by git conflict markers: merge cell by cell or keep one side. Stdlib only.
Author-email: agent-one <rafal.baranowski.iot@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/rafal-one/csv-conflict
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# csv-conflict

Fix a CSV file that git left full of `<<<<<<<` / `=======` / `>>>>>>>` markers. The markers may
sit in the header or inside a quoted multiline field, so the file is not valid CSV. csv-conflict
rebuilds the local and remote versions first, parses each as CSV, then either keeps one side or
merges cell by cell. Best effort, no common ancestor needed. Python 3.9+, stdlib only.

    pip install csv-conflict

    csv-conflict data.csv            # merge: differing cells hold both values
    csv-conflict data.csv --local    # keep our side
    csv-conflict data.csv --remote   # keep their side
    csv-conflict data.csv --key id   # pair rows by id instead of by position

A differing cell becomes one quoted field:

    <<< HEAD
    local value
    ===
    remote value
    >>> feature

## Behaviour
- Merge (default): columns matched by name (remote order, then local-only columns); rows paired by
  position, or by `--key COL` (repeatable; unique, nonempty; rows without a partner are kept as-is).
  Cells compared literally; empty vs nonempty counts as a difference.
- `--local` / `--remote`: only the chosen side must be valid CSV; the other may be broken.
- `--no-header`: headerless files; positional merge, same column count required. With `--key` use 1-based numbers.
- `--separator ';'`, `--encoding windows-1252` (strict, never guesses), LF/CRLF taken from the first line ending.
- Input is replaced atomically (use `-o OUT` to keep it). Empty lines are skipped.
- Warns on stderr with the number of cells that still hold conflicts (`--fail-on-conflicts`: exit 1).
- Exit 2 and file untouched on: malformed/nested/unclosed markers, diff3 ancestor sections, invalid header
  (empty/duplicate names), ragged rows, bad quoting, bad key, bad encoding/separator, unreadable/unwritable file.

## Testing
25 pytest tests, pass on Python 3.9 and 3.14. Clean-venv install of sdist and wheel checked.

## Donate
If it saved you time: https://paypal.me/RafalBaranowski

MIT license.
