From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?Q?S=C3=A9bastien_Brisard?= Subject: Re: How to pass table to SRC block as strings only? Date: Sat, 21 Jan 2017 06:46:22 +0100 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUoVX-0002bG-KM for emacs-orgmode@gnu.org; Sat, 21 Jan 2017 00:46:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cUoVS-00057L-N1 for emacs-orgmode@gnu.org; Sat, 21 Jan 2017 00:46:35 -0500 Received: from mx1.polytechnique.org ([129.104.30.34]:57400) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cUoVS-00056X-CH for emacs-orgmode@gnu.org; Sat, 21 Jan 2017 00:46:30 -0500 Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com [74.125.82.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ssl.polytechnique.org (Postfix) with ESMTPSA id F2036564676 for ; Sat, 21 Jan 2017 06:46:22 +0100 (CET) Received: by mail-wm0-f51.google.com with SMTP id c206so75027111wme.0 for ; Fri, 20 Jan 2017 21:46:22 -0800 (PST) In-Reply-To: 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" To: "Charles C. Berry" Cc: emacs-orgmode@gnu.org Hi again, as a follow up: I can't believe how far behind my org version was (I suppose I was running the built-in version). Now that I have upgraded to 9.0.3, your code works like a charm. Thanks again, S=C3=A9bastien 2017-01-21 6:30 GMT+01:00 S=C3=A9bastien Brisard : > Hi Chuck, > thank you *very much* for this answer! > I was indeed wondering what was the entry point into the org source > for this. `org-babel-ref-resolve' is where I should start. I'm still > relatively new to emacs-lisp and do not know how to instrument the > code in order to trace all calls (which would probably have solved my > problem). > Anyway, with my version (8.2.10) of org-mode, I had to redefine > `org-babel-read' rather than `org-babel--string-to-number'. Will > update and see where it goes. > > In any case, I will consider this problem as solved! Thanks again, > S=C3=A9bastien > > 2017-01-20 4:49 GMT+01:00 Charles C. Berry : >> On Thu, 19 Jan 2017, S=C3=A9bastien 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 cal= l >> 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=3D(get-ref-strings-as-is "table20170119") #+BEGIN_S= RC >> 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 t= his >> more artfully. >> >>> S=C3=A9bastien >>> >>> =3D=3D=3D=3D=3D begin example =3D=3D=3D=3D=3D >>> #+NAME: table20170119 >>> | col1 | col2 | >>> |------+----------------------| >>> | row1 | 12345678901234567890 | >>> | row2 | a | >>> | row3 | b | >>> | row4 | c | >>> >> >> HTH, >> >> Chuck