The context
In #+BEGIN_SRC
code blocks whose language is cpp
or sh
, the tab character is used as a delimiter for cells when using the :results table
header argument (see examples below)
#+begin_src cpp :results replace output table
#include <iostream>
int main() {
std::cout << "a\ta\nbbbbb\tbbbbb" << std::endl;
return 0;
}
#+end_src
#+RESULTS:
| a | a |
| bbbbb | bbbbb |
#+begin_src sh :results replace output table
printf "%s\t%s\n" "a" "a" "bbbbbb" "bbbbbb"
#+end_src
#+RESULTS:
| a | a |
| bbbbbb | bbbbbb |
However, this same behavior is not present in python
code blocks (see below)
#+begin_src python :results replace output table
print("a\ta\nbbbbb\tbbbbb")
#+end_src
#+RESULTS:
: a a
: bbbbb bbbbb
The question
How can I make the output of python
code blocks be displayed as Org tables. Isn't using those header arguments and make the output contain tab characters enough for the #+RESULTS
to be formatted as an Org table?
jupyter-python
and it formats as tables automatically. You can also do this manually with thetabulate
package. I'm not sure how to do it with unchanged Org+Python.