From: Uwe Brauer <oub@mat.ucm.es>
To: emacs-orgmode@gnu.org
Subject: org-tables, export only certain column (csv)
Date: Wed, 24 Jun 2020 13:48:43 +0200 [thread overview]
Message-ID: <87imfgu1k4.fsf@mat.ucm.es> (raw)
Hi
4 years ago Michael Brand provided the following nice solution, which as
far as I know is still not in master.
(add-hook 'org-export-before-processing-hook 'f-ox-filter-table-column-del)
(defun f-ox-filter-table-column-del (back-end)
"Delete the columns $2 to $> marked as \"/\" on a row with \"/\" in $1.
If you want a non-empty column $1 to be deleted make it $2 by
inserting an empty column before or rearrange column order in
some other way. Make sure \"/\" is in $1 again after that."
(while (re-search-forward
"^[ \t]*| +/ +|\\(.*?|\\)?? +\\(/\\) +|" nil t)
(goto-char (match-beginning 2))
(org-table-delete-column)
(beginning-of-line)))
What is this code does can be best explained with the following example
table
| / | <> | <> | <> | <> | <> | <> | / | / | <> |
| | Title | L | M | X | J | V | Obligation | Balance | Past Balance |
|---+------------+-------------+-------------+-------------+-------------+-------------+------------+---------+--------------|
| | Statistics | 11:00-12:00 | 12:00-13:00 | 12:00-12:00 | 12:00-13:00 | | | | |
| | PDE | 12:30-13:30 | | 13:00-14:15 | | 12:30-13:30 | | | |
|---+------------+-------------+-------------+-------------+-------------+-------------+------------+---------+--------------|
| | | | | | | | 21.8 | 2.58 | -0.6 |
When exporting to latex or html the columns Obligation and Balance, will
not be exported (the first one neither).
However his code does not work when exporting it to CSV
I tried the following code
(defun org-table-export-to-xlsx ()
(interactive)
(let* ((source-file (file-name-sans-extension (buffer-file-name (current-buffer))))
(csv-file (concat source-file ".csv")))
(save-excursion
(f-ox-filter-table-column-del nil))
(org-table-export csv-file "orgtbl-to-csv")
(org-odt-convert csv-file "xlsx")))
But all columns are exported.
Does somebody have an idea?
Thanks and regards
Uwe Brauer
next reply other threads:[~2020-06-24 11:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-24 11:48 Uwe Brauer [this message]
2020-09-05 8:47 ` org-tables, export only certain column (csv) Bastien
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87imfgu1k4.fsf@mat.ucm.es \
--to=oub@mat.ucm.es \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).