Re: org-tables, export only certain column (csv)

2020-09-05 Thread Bastien
Hi Uwe,

Uwe Brauer  writes:

> 4 years ago Michael Brand provided the following nice solution, which as
> far as I know is still not in master.

Please let us know if you find a generic solution for this, we could
then add it to worg/org-hacks.org or perhaps.

-- 
 Bastien



org-tables, export only certain column (csv)

2020-06-24 Thread Uwe Brauer


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