On Thu, 19 Jan 2017, Sébastien Brisard wrote:
Thanks Charles for this answer. Let me state the problem more clearly.
Number-like cells *are* converted to numbers (as best illustrated by
the example below (see the use of numberp), which might incur accuracy
loss (see below, the first row has a lot of significant digits).
I am not interested in the number representation of these cells, only
the string matters for my application. Due to this accuracy loss,
converting back the number to a string is not an option for me...
Any ideas? Thanks!
The usual resolution of table references will eventually use
`org-babel--string-to-number' to do what its name suggests.
You can write an elisp function to handle references as you wish and call
them from :var arguments.
A hackish way to do this for your case is to quash the action of
`org-babel--string-to-number':
#+BEGIN_SRC emacs-lisp
(defun get-ref-strings-as-is (ref)
(cl-letf (((symbol-function 'org-babel--string-to-number)
(lambda (x) x)))
(org-babel-ref-resolve ref)))
#+END_SRC
#+header: :var table=(get-ref-strings-as-is "table20170119")
#+BEGIN_SRC emacs-lisp :colnames yes :results pp
table
#+END_SRC
#+RESULTS:
: (("row1" "12345678901234567890")
: ("row2" "a")
: ("row3" "b")
: ("row4" "c"))
You can look at `org-babel-ref-resolve' to get some ideas on how to do
this more artfully.
Sébastien
===== begin example =====
#+NAME: table20170119
| col1 | col2 |
|------+----------------------|
| row1 | 12345678901234567890 |
| row2 | a |
| row3 | b |
| row4 | c |
HTH,
Chuck