{"id":13857049,"url":"https://github.com/msalvaris/nbtoolz","last_synced_at":"2025-07-13T19:34:00.439Z","repository":{"id":111657693,"uuid":"154117706","full_name":"msalvaris/nbtoolz","owner":"msalvaris","description":"Set of tools for Jupyter notebooks","archived":false,"fork":false,"pushed_at":"2018-12-12T13:18:35.000Z","size":64,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-08-06T03:02:58.659Z","etag":null,"topics":["git","jupyter"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msalvaris.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-10-22T09:26:46.000Z","updated_at":"2022-07-07T16:41:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"fd1704c3-9f35-411f-94a0-c31cda03b850","html_url":"https://github.com/msalvaris/nbtoolz","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msalvaris%2Fnbtoolz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msalvaris%2Fnbtoolz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msalvaris%2Fnbtoolz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msalvaris%2Fnbtoolz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msalvaris","download_url":"https://codeload.github.com/msalvaris/nbtoolz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225912491,"owners_count":17544187,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git","jupyter"],"created_at":"2024-08-05T03:01:24.007Z","updated_at":"2024-11-22T14:31:47.321Z","avatar_url":"https://github.com/msalvaris.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Introduction \nThis app offers methods to run on notebooks to ensure no sensitive information is contained in the cell or sensitive \noutput is removed.\n\nIt is built using Python Fire so the interface is a little peculiar \u003e:)\n\n# Installation\nTo install you can simply run the following\n```bash\npip install git+https://github.com/msalvaris/nbtoolz.git\n```\n\nIt has been tested on Ubuntu but should run on Windows. \n\n# How to Use\nThe app offer 4 methods, 2 that alter the context and 2 that are used as the final output. *strip_output* and *replace* \nalter the contents of the notebook. *print* prints the output of the processing to the terminal and *write*  \nwrites the result of the transformations to the file specified. Additionally, you can *overwrite*, which simply writes the results back to the input file.\n\nIn the example below we will strip out cells tagged with strip_out tag and replace Team B with \u003cYOUR_TEAM\u003e and print \nout the results to the terminal.\n```bash\nnbtoolz read test.ipynb - strip_output strip_out replace \"Team B\" \"\u003cYOUR_TEAM\u003e\" print\n```\n\nThe default tag for strip_output is strip_out so the following does the same.\n```bash\nnbtoolz read test.ipynb - strip_output - replace \"Team B\" \"\u003cYOUR_TEAM\u003e\" print\n```\n\nTo tag a cell simply select tags in the cell output menu   \n![Tag menu Jupyter](images/tag_menu.PNG \"Tag Menu\")\n\nand add the tag in the text box above the cell  \n![Tag Jupyter](images/tag.PNG \"Tag\")\n\nWe can also chain more methods\n```bash\nnbtoolz read test.ipynb - strip_output - replace \"Team B\" \"\u003cYOUR_TEAM\u003e\" replace \"TEAM A\" \"\u003cYOUR_TEAM\u003e\" print\n```\n\nTo write the output to the file simply run write at the end\n```bash\nnbtoolz read test.ipynb - strip_output - replace \"Team B\" \"\u003cYOUR_TEAM\u003e\" replace \"TEAM A\" \"\u003cYOUR_TEAM\u003e\" write out.ipynb\n```\n\nIt also accepts a list of files\n```bash\nnbtoolz read test.ipynb test2.iynb - strip_output - replace \"Team B\" \"\u003cYOUR_TEAM\u003e\" replace \"TEAM A\" \"\u003cYOUR_TEAM\u003e\" write out.ipynb out2.ipynb\n```\n\nor wildcards\n```bash\nnbtoolz read *.ipynb - strip_output - replace \"Team B\" \"\u003cYOUR_TEAM\u003e\" replace \"TEAM A\" \"\u003cYOUR_TEAM\u003e\" write\n```\n\nYou can also overwrite your input file\n```bash\nnbtoolz read test.ipynb - strip_output - replace \"Team B\" \"\u003cYOUR_TEAM\u003e\" replace \"TEAM A\" \"\u003cYOUR_TEAM\u003e\" overwrite\n```\n\n# Configure git filter\nYou can configure git filter to use nbtoolz to ensure that you never commit any sensitive information. To do so once you\nhave installed nbtoolz\n\nSimply create a shell script called nbfilter that accepts a single argument and add it to your path or .bashrc\n```bash\n#!/usr/bin/env bash\n\nnbtoolz read-stdin strip_output - replace \"Team\" \"\u003cYOUR_SUBSCRIPTION\u003e\" replace \"Team2\" \"\u003cYOUR_SUBSCRIPTION\u003e\" print\n\n```\n\nThen you can either edit the .git/config file and add the following\n```text\n[filter \"nbclean\"]\n    clean = nbfilter\n    smudge = cat\n```\n\nor run the following commands\n\n```bash\ngit config filter.nbclean.clean nbfilter\ngit config filter.nbclean.smudge cat\ngit config filter.nbclean.required true\n```\n\nthen create a .gitattributes file in your project directory and add the following\n```text\n*.ipynb filter=nbclean\n```\n\n\n# Contribute\nPlease post issues, PRs welcome :)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsalvaris%2Fnbtoolz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsalvaris%2Fnbtoolz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsalvaris%2Fnbtoolz/lists"}