emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] How to pass table to SRC block as strings only?


From: Charles C. Berry
Subject: Re: [O] How to pass table to SRC block as strings only?
Date: Thu, 19 Jan 2017 09:07:29 -0800
User-agent: Alpine 2.20 (OSX 67 2015-01-07)

On Thu, 19 Jan 2017, Sébastien Brisard wrote:

Hello all,
here is a MWE

=====BEGIN MWE=====

#+NAME: table20170119
| col1 | col2       |
|------+------------|
| row1 | 1234567890 |
| row2 | a          |
| row3 | b          |
| row4 | c          |

#+BEGIN_SRC emacs-lisp :var table=table20170119 :colnames yes :results output
 (print (map 'list (lambda (row) (nth 1 row)) table))
#+END_SRC

#+RESULTS:
:
: (1234567890.0 "a" "b" "c")

=====END MWE=====

As you can see, col #1, row #1 is parsed as a float.


Actually, it is not a float:

#+BEGIN_SRC emacs-lisp :var table=table20170119 :colnames yes :results pp
(number-to-string (nth 1 (car table)))
#+END_SRC

#+RESULTS:
: "1234567890"

Maybe this is what you want:

#+BEGIN_SRC emacs-lisp :var table=table20170119 :colnames yes :results pp
(map 'list (lambda (row) (format "%s" (nth 1 row))) table)
#+END_SRC

#+RESULTS:
: ("1234567890" "a" "b" "c")

HTH,

Chuck

reply via email to

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