How to remove control sequence or ANSI color or ANSI Escape codes from grep output of the jupyter notebook file?
This is the sample part of the saved ipynb file.
"text": [
"\u001b[32m2023-12-08 00:32:30.319\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mtimeit\u001b[0m:\u001b[36minner\u001b[0m:\u001b[36m6\u001b[0m - \u001b[1msdfsdfsdf\u001b[0m\n",
]
To create the ipynb file, execute the code in the cell of jupyter.
#install loguru if needed
#%pip install loguru
import timeit
timeit.timeit(setup="from loguru import logger", stmt='''logger.info('sdfsdfsdf')''', number=2)
I use jupyter-notebook6.
you can install with python3 -m pip install notebook==6.5.7.
you can start the notebook server with jupyter-notebook shell command after installation.
To install loguru lib, execute %pip install loguru in the cell of jupyter-notebook.
However, it doesn't mean it's the specific lib's problem. Such a attribute error can show the codes I want to remove.
you can view the text of the ipynb file.
grep -r timeit output is
#zsh grep (bsd)
./python3.ipynb: "\u001b[32m2023-12-08 00:32:30.319\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mtimeit\u001b[0m:\u001b[36minner\u001b[0m:\u001b[36m6\u001b[0m - \u001b[1msdfsdfsdf\u001b[0m\n",
#bash grep (gnu)
python3.ipynb: "\u001b[32m2023-12-08 00:32:30.319\u001b[0m | \u001b[1mINFO \u001b[0m | \u001b[36mtimeit\u001b[0m:\u001b[36minner\u001b[0m:\u001b[36m6\u001b[0m - \u001b[1msdfsdfsdf\u001b[0m\n",
What I expect is
#zsh grep (bsd)
./python3.ipynb: "2023-12-08 00:32:30.319 | INFO | timeit:inner:6 - sdfsdfsdf\n",
#bash grep (gnu)
python3.ipynb: "2023-12-08 00:32:30.319 | INFO | timeit:inner:6 - sdfsdfsdf\n",

