[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Converting table to properties
From: |
Juan Pechiar |
Subject: |
Re: [O] Converting table to properties |
Date: |
Wed, 6 Jun 2012 10:06:38 -0300 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
On Wed, Jun 06, 2012 at 05:55:52PM +0530, Vikas Rawal wrote:
> I have a table under each of several headlines in an org file. Each
> table has a row of column labels and a row of data. I would like to
> convert the table into properties, with labels coming from first row
> and values of properties coming from the second row.
>
> How should I do this?
Hi Vikas,
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:
Hope it helps.
.j.