kynan / nbstripout

strip output from Jupyter and IPython notebooks
Other
1.19k stars 94 forks source link

Strip output_type=stderr only, with keep_output? #175

Open indigoviolet opened 1 year ago

indigoviolet commented 1 year ago

Is there a way to configure nbstripout to strip certain types of output?

A workaround is jq 'del(.cells[] | select(.cell_type=="code") | .outputs[] | select(.name=="stderr"))', but it would be nice to do this sort of thing in nbstripout directly

kynan commented 1 year ago

I don't understand what exactly you're asking for?

indigoviolet commented 1 year ago
❯ jq -c '.cells[] |select(.cell_type=="code")| .outputs[] | {"name": .name, "output_type": .output_type}' company_data.ipynb | sort | uniq
{"name":null,"output_type":"display_data"}
{"name":null,"output_type":"error"}
{"name":null,"output_type":"execute_result"}
{"name":"stderr","output_type":"stream"}
{"name":"stdout","output_type":"stream"}

I see many different types of output in a single notebook (multiple types for a single cell --- stderr, stdout, error, result etc), and would like control over which are stripped and which are kept, above and beyond the keep_output tag which keeps all outputs if present.

kynan commented 1 year ago

Gotcha. Do you have an example notebook that could be used to test this @indigoviolet ?

kynan commented 1 year ago

@indigoviolet Do you have an example notebook that could be used to test this?