From mboxrd@z Thu Jan 1 00:00:00 1970 From: Juan Pechiar Subject: Re: Converting table to properties Date: Wed, 6 Jun 2012 10:06:38 -0300 Message-ID: <20120606130638.GC6258@soloJazz.com> References: <-8912430512402798276@unknownmsgid> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from eggs.gnu.org ([208.118.235.92]:44082) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ScFwq-0004fn-MD for emacs-orgmode@gnu.org; Wed, 06 Jun 2012 09:06:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ScFwl-0001Ig-Nm for emacs-orgmode@gnu.org; Wed, 06 Jun 2012 09:06:52 -0400 Received: from oproxy6-pub.bluehost.com ([67.222.54.6]:58291) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1ScFwl-0001I1-7w for emacs-orgmode@gnu.org; Wed, 06 Jun 2012 09:06:47 -0400 Content-Disposition: inline In-Reply-To: <-8912430512402798276@unknownmsgid> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Vikas Rawal Cc: org-mode mailing list 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.