From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id WDInJsI9816xeAAA0tVLHw (envelope-from ) for ; Wed, 24 Jun 2020 11:49:22 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id QFf7IcI9814VIQAA1q6Kng (envelope-from ) for ; Wed, 24 Jun 2020 11:49:22 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 006149404C3 for ; Wed, 24 Jun 2020 11:49:22 +0000 (UTC) Received: from localhost ([::1]:43252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jo3u3-0007M1-GT for larch@yhetil.org; Wed, 24 Jun 2020 07:49:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jo3tg-0007LO-St for emacs-orgmode@gnu.org; Wed, 24 Jun 2020 07:48:57 -0400 Received: from ciao.gmane.io ([159.69.161.202]:59796) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jo3tf-0007Ch-0x for emacs-orgmode@gnu.org; Wed, 24 Jun 2020 07:48:56 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jo3ta-0009aD-KU for emacs-orgmode@gnu.org; Wed, 24 Jun 2020 13:48:50 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-orgmode@gnu.org To: emacs-orgmode@gnu.org From: Uwe Brauer Subject: org-tables, export only certain column (csv) Date: Wed, 24 Jun 2020 13:48:43 +0200 Message-ID: <87imfgu1k4.fsf@mat.ucm.es> Mime-Version: 1.0 Content-Type: text/plain User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cancel-Lock: sha1:tEk9JGzb5G5yPgbJjrzAzcj4Wao= Mail-Copies-To: never Received-SPF: pass client-ip=159.69.161.202; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/24 07:48:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -8 X-Spam_score: -0.9 X-Spam_bar: / X-Spam_report: (-0.9 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=mat.ucm.es (policy=none); spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -0.41 X-TUID: OEO11RpMd/a8 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