emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Converting table to properties


From: Vikas Rawal
Subject: Re: [O] Converting table to properties
Date: Fri, 8 Jun 2012 05:14:00 +0530





This is a quick hack on org-table-transpose-table-at-point to print
out a property list instead of a table.

#+begin_src elisp

(defun vikas-convert ()
 "table to props"
 (interactive)
 (let ((contents
        (apply #'mapcar* #'list
               ;; remove 'hline from list
                  (delq nil (mapcar (lambda (x) (when (listp x) x))
                                      (org-table-to-lisp))))))
   (delete-region (org-table-begin) (org-table-end))
   (insert "  :PROPERTIES:\n")
   (insert (mapconcat (lambda(x) (concat "  :" (first x) ": " (second
   x) "\n" ))
                      contents ""))
   (insert "  :END:\n\n")))

#+end_src

This transforms:

| PROP1 | PROP2 | PROP3 |
| 1     | 2     | 3     |

into

 :PROPERTIES:
 :PROP1: 1
 :PROP2: 2
 :PROP3: 3
 :END:


Your code worked flawlessly. Thank you.

Vikas

reply via email to

[Prev in Thread] Current Thread [Next in Thread]