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.2

  • Minor edits to documentation and README formatting.

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.1
  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.2.tar.gz (3.9 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.2-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nbstrip_empty_cells-0.1.2.tar.gz
  • Upload date:
  • Size: 3.9 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.2.tar.gz
Algorithm Hash digest
SHA256 84e9f840da17442dbbf454768d454154b1d7659edc07236eeaec9cfd36f9a403
MD5 3301103cb4279bba7a9d5dd929bd8c23
BLAKE2b-256 56f2ce262e70a51a2e0329a6225291995bf79c82330eae371c7387c0dcec3934

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nbstrip_empty_cells-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2594a3c90ace211bd53cdd34c9f8397a895c5e66b5d8d498acf0b6b2ad43b528
MD5 e86631ce925f6d8d31174fc932f7d581
BLAKE2b-256 05e4b232b4b00c7ca53c5790649853a3e2478b0a21ff00483981375bba6ec1fb

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