Skip to main content

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.

Metadata

Release files for csv-conflict 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for csv-conflict 0.1.0
File Size Uploaded
csv_conflict-0.1.0.tar.gz 7.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for csv-conflict 0.1.0
File Interpreter ABI Platform
csv_conflict-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.3 kB

Release files / csv_conflict-0.1.0.tar.gz

Download URL csv_conflict-0.1.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a3cceb0f0e28e69e1ea7e5d8bc0acb04eef2897b08fec54ccc4d21eb16dff97d
BLAKE2b-256 checksum
How to use checksums
3bed17babbd9ba568c772d630d56e8e47d4fe1df30f67fd56286e6c905a8e03e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / csv_conflict-0.1.0-py3-none-any.whl

Download URL csv_conflict-0.1.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
452eb441c535c6941fa5ca862a9efc10a83bb9a3d4b040b096d4cf10ef876478
BLAKE2b-256 checksum
How to use checksums
5227e13f7d646c955e539414dfbca89aa41e830eabc17102fcd0277c12bde003
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page