lukascbossert
lukascbossert

Reputation: 411

How to export results to file *and* below the source-block with org-babel?

I habe a table which looks like this

#+tblname:students
| Name   | subject         | grade |
|--------+-----------------+-------|
| Hans   | History Sport   |     2 |
| Dieter | Sport Maths     |     3 |
| Silke  | History Science |     1 |
| Elke   | Chemistry Latin |     4 |
| Udo    | English Maths   |     2 |
|--------+-----------------+-------|

I want to convert it to csv with:

#+name: students-csv
#+BEGIN_SRC elisp :var x=students
(orgtbl-to-csv x nil)
#+END_SRC

which works great and I get the results below the source block:

#+RESULTS: students-csv
: Name,subject,grade
: Hans,History Sport,2
: Dieter,Sport Maths,3
: Silke,History Science,1
: Elke,Chemistry Latin,4
: Udo,English Maths,2

However I want to get the csv-results exported to a file, too. I can get this with this header argument:

#+name: students-csv
#+BEGIN_SRC elisp :var x=students :results both  file    :exports both  :file students.csv
(orgtbl-to-csv x nil)
#+END_SRC

And the file is generated and I get a link to the file.

#+RESULTS: students-csv
[[file:students.csv]]

Question: How do I get the results below and exported to a file at the same time without repeating the source-blocks?

Upvotes: 2

Views: 958

Answers (0)

Related Questions