Skip to main content

modify-csv

Apply a user-provided Python function to every cell in one CSV data row, every cell in one column, or one cell. The CSV's first record is treated as its header and is never modified. Row and column indexes are zero-based; columns can also be addressed by their exact header text.

Install

Install a published release from PyPI:

python -m pip install modify-csv

Or install a tagged version directly from the private GitHub repository using SSH authentication:

python -m pip install "git+ssh://git@github.com/martinjose/modify-csv.git@v0.1.0"

Git and access to the private repository are required for the second form. Each GitHub Release also provides a universal wheel and source archive.

For local development, install an editable copy:

python -m pip install -e .

This installs the modify-csv command. You can also run the package without an installation using PYTHONPATH=src python -m modify_csv.

Script contract

The supplied script must define exactly this callable shape:

from typing import Any


def eval(content: Any, row: int, col: int) -> Any:
    return content

Any is provided by Python's standard-library typing module. The function name, parameter names, and three-argument shape are enforced.

content is the current CSV field (initially a string), while row and col are zero-based numeric indexes into the data records and columns. The returned value is passed to Python's CSV writer. The script is ordinary trusted Python and executes with the same permissions as the command.

Examples

Apply a script file to a column selected by header:

modify-csv apply input.csv output.csv --script-file normalize.py --column email

Apply inline code to data row 2:

modify-csv apply input.csv output.csv \
  --script 'def eval(content, row, col): return content.strip()' \
  --row 2

Apply inline code to the cell at data row 0 and column 1:

modify-csv apply input.csv output.csv \
  --script 'def eval(content, row, col): return int(content) * 2' \
  --cell 0 1

Exactly one of --script or --script-file, and exactly one of --row, --column, or --cell, is required. Existing output files are protected; pass --force to replace one.

Generate a ready-to-edit transformation script:

modify-csv template transform.py

Use --force to replace an existing template. Run modify-csv --help or the help for either subcommand to see the required function signature. The original form without the apply subcommand remains supported for compatibility.

Releasing

Versions follow YYYY.M.RELEASE, where RELEASE starts at 1 each month. For example, the first release in October 2026 is 2026.10.1.

Preview the next version without changing the repository:

python scripts/release.py next

To update pyproject.toml, create the release commit, and create an annotated tag locally for inspection:

python scripts/release.py prepare

The command prints the exact push command to use after reviewing the commit and tag. To prepare and push both atomically in one step instead, run:

python scripts/release.py release

Release preparation requires a clean main branch. The package version in pyproject.toml remains the release source of truth. Pushing the generated tag starts the GitHub Actions release process:

git push --atomic origin main v2026.10.1

The tag-triggered release workflow tests Python 3.10 and 3.13 on Linux, macOS, and Windows. It then builds and validates a platform-independent wheel and source archive, publishes them to TestPyPI through trusted publishing, verifies that the package installs and runs from TestPyPI, and stages the exact artifacts in a draft GitHub Release.

After reviewing the successful run, open Actions, select Release, choose Run workflow, and enter the tag. This explicit manual action verifies and publishes the staged artifacts to PyPI, then publishes the draft GitHub Release. A mismatched version and tag, missing draft release, or changed artifact causes the production run to fail.

Trusted publishers must be configured independently on TestPyPI and PyPI. Both use owner martinjose, repository modify-csv, and workflow release.yml. The TestPyPI publisher uses environment testpypi; the production publisher uses environment pypi. The manually dispatched production run serves as the approval gate for private repositories without environment reviewer support.

Metadata

Release files for modify-csv 2026.10.4

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

Source distribution (sdist)

Source distribution for modify-csv 2026.10.4
File Size Uploaded Provenance
modify_csv-2026.10.4.tar.gz 9.9 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for modify-csv 2026.10.4
File Interpreter ABI Platform
modify_csv-2026.10.4-py3-none-any.whl Python 3 none any Details

Total release size: 18.1 kB

Release files / modify_csv-2026.10.4.tar.gz

Download URL modify_csv-2026.10.4.tar.gz
Size 9.9 kB
Tags Source
SHA-256 checksum
How to use checksums
07b567e8855ee90b5b089b72703bbe9b44009ad983ef4f0c8c53c0c444008ed6
BLAKE2b-256 checksum
How to use checksums
ac839555ea4996c013e61b67be50f62b631a1486ae50d5485f2c9f262e2be4e3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Release files / modify_csv-2026.10.4-py3-none-any.whl

Download URL modify_csv-2026.10.4-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c175d5c3b589c796242264997352595f2877d33a7892eba7357950e3b881133
BLAKE2b-256 checksum
How to use checksums
0e456f75cd298f6171130b2fc587d733efea7843dde3279211161493b195b1df
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

Security for modify-csv 2026.10.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for modify_csv-2026.10.4.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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