emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* export only certain columns of an org-table to csv
@ 2023-04-08 17:26 Uwe Brauer
  2023-04-09  8:51 ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Brauer @ 2023-04-08 17:26 UTC (permalink / raw)
  To: emacs-orgmode



Hi 

I have the following simple table


#+Name: table
| / | /      | <>     | <>     |
|   | Name   | Sheet1 | Sheet2 |
|---+--------+--------+--------|
|   | Smith  | Ex1    | Ex2    |
|   | Miller | Ex3    | Ex4    |


I hoped that the first two columns would not be exported to csv
(orgtbl-to-csv), indeed they are not when exporting to latex or html but
for csv, all columns have been exported.

What do I miss?

Thanks and regards

Uwe Brauer 

-- 
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: export only certain columns of an org-table to csv
  2023-04-08 17:26 export only certain columns of an org-table to csv Uwe Brauer
@ 2023-04-09  8:51 ` Ihor Radchenko
  2023-04-09  9:38   ` Uwe Brauer
  0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2023-04-09  8:51 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-orgmode

Uwe Brauer <oub@mat.ucm.es> writes:

> I have the following simple table
>
>
> #+Name: table
> | / | /      | <>     | <>     |
> |   | Name   | Sheet1 | Sheet2 |
> |---+--------+--------+--------|
> |   | Smith  | Ex1    | Ex2    |
> |   | Miller | Ex3    | Ex4    |
>
>
> I hoped that the first two columns would not be exported to csv
> (orgtbl-to-csv), indeed they are not when exporting to latex or html but
> for csv, all columns have been exported.

> What do I miss?

The second column get exported to latex and html on my side.
And it is expected. Only the first column with spacial marks does not
get exported. All other columns are exported, unless you specify
:skipcols (see `orgtbl-to-generic' docstring).

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: export only certain columns of an org-table to csv
  2023-04-09  8:51 ` Ihor Radchenko
@ 2023-04-09  9:38   ` Uwe Brauer
  2023-04-14 12:03     ` Ihor Radchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Uwe Brauer @ 2023-04-09  9:38 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 2016 bytes --]

>>> "IR" == Ihor Radchenko <yantar92@posteo.net> writes:

> Uwe Brauer <oub@mat.ucm.es> writes:
>> I have the following simple table
>> 
>> 
>> #+Name: table
>> | / | /      | <>     | <>     |
>> |   | Name   | Sheet1 | Sheet2 |
>> |---+--------+--------+--------|
>> |   | Smith  | Ex1    | Ex2    |
>> |   | Miller | Ex3    | Ex4    |
>> 
>> 
>> I hoped that the first two columns would not be exported to csv
>> (orgtbl-to-csv), indeed they are not when exporting to latex or html but
>> for csv, all columns have been exported.

>> What do I miss?

> The second column get exported to latex and html on my side.
Well, well memory fails.
https://list.orgmode.org/874koc38zn.fsf@gnu.org/T/

I asked a similar question three years ago, the first two columns are
not exported because of this

(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)))

But it is not working for the csv export  would be nice if it would

> And it is expected. Only the first column with spacial marks does not
> get exported. All other columns are exported, unless you specify
> :skipcols (see `orgtbl-to-generic' docstring).

-- 
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: export only certain columns of an org-table to csv
  2023-04-09  9:38   ` Uwe Brauer
@ 2023-04-14 12:03     ` Ihor Radchenko
  2023-04-14 12:14       ` Uwe Brauer
  0 siblings, 1 reply; 5+ messages in thread
From: Ihor Radchenko @ 2023-04-14 12:03 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-orgmode

Uwe Brauer <oub@mat.ucm.es> writes:

> I asked a similar question three years ago, the first two columns are
> not exported because of this
>
> (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)))
>
> But it is not working for the csv export  would be nice if it would

This one is tricky.
Table export is intentionally decoupled from general export settings:

6d2ab4071960f8a7f20138291424b468722ab522
Author:     Nicolas Goaziou <mail@nicolasgoaziou.fr>
org-table: Fix radio tables containing macros

* lisp/org-table.el (orgtbl-to-generic): Export macros as-is, even if
  they are undefined.
* testing/lisp/test-org-table.el (test-org-table/to-generic): Add test.

Radio tables are now using a minimal set-up for export.  In particular,
no macro is expanded, and no Babel code is executed.  If any of these is
needed, use `org-export-string-as' or `org-export-region-as' instead.

Reported-by: Mark Edgington <edgimar@gmail.com>
<http://permalink.gmane.org/gmane.emacs.orgmode/100621>

-----

I understand that the suggested `org-export-region-as' will not work
because we don't have ox-csv. And changing the way table export works
may cause unforeseen consequences.

I have to think how to approach this problem.

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: export only certain columns of an org-table to csv
  2023-04-14 12:03     ` Ihor Radchenko
@ 2023-04-14 12:14       ` Uwe Brauer
  0 siblings, 0 replies; 5+ messages in thread
From: Uwe Brauer @ 2023-04-14 12:14 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: Uwe Brauer, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1096 bytes --]


> Uwe Brauer <oub@mat.ucm.es> writes:

> This one is tricky.


> Table export is intentionally decoupled from general export settings:

I see, that explains it.


[Snip]…


> I understand that the suggested `org-export-region-as' will not work
> because we don't have ox-csv. And changing the way table export works
> may cause unforeseen consequences.

> I have to think how to approach this problem.


Ok fair enough. It would be great if that could be solved. 

meanwhile a complicated workoround is to export it to ods[1] in which
case the filter works and then back to csv, but that is rather
cumbersome.



Footnotes:
[1]  using an unofficial org-odt filter git@github.com:kjambunathan/org-mode-ox-odt.git

-- 
Warning: Content may be disturbing to some audiences
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 
https://addons.thunderbird.net/en-US/thunderbird/addon/gmail-conversation-view/

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-04-14 12:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-08 17:26 export only certain columns of an org-table to csv Uwe Brauer
2023-04-09  8:51 ` Ihor Radchenko
2023-04-09  9:38   ` Uwe Brauer
2023-04-14 12:03     ` Ihor Radchenko
2023-04-14 12:14       ` Uwe Brauer

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).