Skip to main content

Remove empty code and markdown cells from Jupyter notebooks (ideal for pre-commit hooks)

Project description

nbstrip-empty-cells

Downloads PyPI version License: MIT

v0.1.3

  • Minor edits to documentation and README formatting.
  • CLI refference: nbstrip-empty-cell from v0.1.0, v0.1.1 -> nbstrip-empty-cells
  • nbstrip-empty-cells works in v0.1.2 & v0.1.3

What this Hook Does

This hook automatically removes empty code and markdown cells from Jupyter notebooks before they are committed. It helps keep your notebooks clean and version control diffs minimal.

Why use this Tool:

  • Avoid noisy diffs from empty cells.
  • Keep your notebooks clean and readable, especially in version control.
  • Seamlessly integrates with your Git workflow via pre-commit
  • Safe to run on mixed repositories — non-.ipynb files are ignored.

Example usage with pre-commit & pip

Add to your .pre-commit-config.yaml in your notebook repository:

- repo: https://github.com/Drew5040/nbstrip-empty-cell
  rev: v0.1.3
  hooks:
    - id: nbstrip-empty-cells

Then install pre-commit in your local repository:

pre-commit install

Update all hook versions:

pre-commit autoupdate

Then run the hook (nbstrip-empty-cells) manually on all files (safe to do so):

pre-commit run --all-files

Installation & Usage via pip & CLI (Optional)

pip install nbstrip-empty-cells

nbstrip-empty-cells notebook1.ipynb notebook2.ipynb 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nbstrip_empty_cells-0.1.3.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nbstrip_empty_cells-0.1.3-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file nbstrip_empty_cells-0.1.3.tar.gz.

File metadata

  • Download URL: nbstrip_empty_cells-0.1.3.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for nbstrip_empty_cells-0.1.3.tar.gz
Algorithm Hash digest
SHA256 164f38ba747cdc2955888bda695d6289272b7349fa5f6adb3f5d3bc919908ad9
MD5 fadf2ba37ae413ea6e5efebf4ddd7868
BLAKE2b-256 5e884b5e0bd7721da1264a474035383ad384cc9ff1e62b777df2e8ea8bc702ef

See more details on using hashes here.

File details

Details for the file nbstrip_empty_cells-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for nbstrip_empty_cells-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5e291f86d51bff16ac3d90c3b6c638cc785501f1dd9c7d872228bc13c4190d3e
MD5 1b49d208d2552277ab94143e032c3ec3
BLAKE2b-256 ba0768facf7c5ac1008308172a311921c258cd34ea6533a9f9e3443fd4e336f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page