Closed jonahpearl closed 2 years ago
Hi @jonahpearl , indeed it is possible to pair files with a suffix. This appears briefly in the documentation at https://jupytext.readthedocs.io/en/latest/config.html, but I do agree that we could improve that part of the documentation.
An example is this one:
jupytext --to .nb.py:percent notebook.ipynb
to convert notebook.ipynb
to notebook.nb.py
in the py:percent
format.
You can also use this syntax in the formats
option, see for instance this test.
Ah great, thank you. I was thinking that the [suffix]:percent had to be a specific string to invoke the percent format. But you’re saying I could do, for instance, jupytext --to my_new_file.py:percent ./*/**/*.ipynb
and it will know that there’s an implied wildcard in front of “my_new_file”?
On Jul 13, 2022, at 3:58 PM, Marc Wouts @.***> wrote:
Hi @jonahpearl https://github.com/jonahpearl , indeed it is possible to pair files with a suffix. This appears briefly in the documentation at https://jupytext.readthedocs.io/en/latest/config.html https://jupytext.readthedocs.io/en/latest/config.html, but I do agree that we could improve that part of the documentation.
An example is this one:
jupytext --to .nb.py:percent notebook.ipynb to convert notebook.ipynb to notebook.nb.py in the py:percent format.
You can also use this syntax in the formats option, see for instance this test https://github.com/mwouts/jupytext/blob/8a4ea5f18993c73e5d33c665be3637e85d639df7/tests/test_cli.py#L783-L807.
— Reply to this email directly, view it on GitHub https://github.com/mwouts/jupytext/issues/979#issuecomment-1183621318, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQKOLZHZKPXZSYCPY4ZFK2DVT4NW3ANCNFSM53MQEMPA. You are receiving this because you were mentioned.
I think so! Maybe I'll let you try and confirm?
Yup, appears to work. Thanks!
(Also ps: I used this to write a small script to convert ipynb's from 2-space tabs to 4-space tabs. Not the intended use-case but very handy! If I get a chance I will update the gist with this streamlined verison! https://gist.github.com/jonahpearl/5bd84ee032911ee0b0c32f773a9b511e)
Awesome, thank you @jonahpearl
Hi there, I'm wondering if there's a way to append a custom suffix to files. It would be great to be able to do, eg,
jupytext --to py ./**/*.ipynb --suffix my_converted_script
. I wrote a bash script to do this file by file but seems like a quick add in Python that would save others having to write a script. Am I missing an obvious way to do this with the current options? Thanks.