[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] table as argument to code block : type of the elements
From: |
Nick Dokos |
Subject: |
Re: [O] table as argument to code block : type of the elements |
Date: |
Fri, 13 Sep 2013 00:41:21 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
address@hidden writes:
> This code does not work because of automatic conversion from string to
> number in org-babel-read-table.
>
> #+TBLNAME: table_test
> | name | id |
> |-------+-----|
> | name1 | 034 |
> | name2 | 135 |
> | name3 | 1B5 |
>
> #+NAME: code_test
> #+BEGIN_SRC emacs-lisp :var table=table_test
> (setq myv "")
> (dolist (line table myv)
> (unless (eq line 'hline)
> (setq myv (concat myv ";" (mapconcat 'identity line ",")))))
> myv
>
> #+END_SRC
>
> I would like to have this result :
>
> #+RESULTS: code_test
> : ;name,id;name1,034;name2,135;name3,1B5
>
> Is there any possibility to deactivate this conversion as with
> inhibit-lisp-eval for lisp forms ? Or better is there any way to chose
> conversion parameters on a column to column basis ?
>
Not that I know of. But you can redefine org-babel-read-table to omit
the conversion:
--8<---------------cut here---------------start------------->8---
(defun org-babel-read-table ()
(org-table-to-lisp))
--8<---------------cut here---------------end--------------->8---
and redefine it back afterwards:
--8<---------------cut here---------------start------------->8---
(defun org-babel-read-table ()
"Read the table at `point' into emacs-lisp."
(mapcar (lambda (row)
(if (and (symbolp row) (equal row 'hline)) row
(mapcar (lambda (el) (org-babel-read el 'inhibit-lisp-eval))
row)))
(org-table-to-lisp)))
--8<---------------cut here---------------end--------------->8---
Disgusting, no?
--
Nick