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: Fri, 20 Jan 2017 03:34:45 +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]:60507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cUP2V-0001nw-VJ for emacs-orgmode@gnu.org; Thu, 19 Jan 2017 21:34:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cUP2Q-0002lg-V8 for emacs-orgmode@gnu.org; Thu, 19 Jan 2017 21:34:55 -0500 Received: from mx1.polytechnique.org ([129.104.30.34]:42752) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cUP2Q-0002ky-Jq for emacs-orgmode@gnu.org; Thu, 19 Jan 2017 21:34:50 -0500 Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) (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 7F5285648A6 for ; Fri, 20 Jan 2017 03:34:46 +0100 (CET) Received: by mail-wm0-f41.google.com with SMTP id c206so22747851wme.0 for ; Thu, 19 Jan 2017 18:34:46 -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" , emacs-orgmode@gnu.org 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! 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 | #+BEGIN_SRC emacs-lisp :var table=3Dtable20170119 :colnames yes :results ou= tput (print (map 'list (lambda (row) (nth 1 row)) table)) #+END_SRC #+RESULTS: : : (1.2345678901234567e+019 "a" "b" "c") #+BEGIN_SRC emacs-lisp :var table=3Dtable20170119 :colnames yes :results va= lue (map 'list (lambda (row) (numberp (nth 1 row))) table) #+END_SRC #+RESULTS: | t | nil | nil | nil | =3D=3D=3D=3D=3D end example =3D=3D=3D=3D=3D 2017-01-19 18:07 GMT+01:00 Charles C. Berry : > On Thu, 19 Jan 2017, S=C3=A9bastien Brisard wrote: > >> Hello all, >> here is a MWE >> >> =3D=3D=3D=3D=3DBEGIN MWE=3D=3D=3D=3D=3D >> >> #+NAME: table20170119 >> | col1 | col2 | >> |------+------------| >> | row1 | 1234567890 | >> | row2 | a | >> | row3 | b | >> | row4 | c | >> >> #+BEGIN_SRC emacs-lisp :var table=3Dtable20170119 :colnames yes :results >> output >> (print (map 'list (lambda (row) (nth 1 row)) table)) >> #+END_SRC >> >> #+RESULTS: >> : >> : (1234567890.0 "a" "b" "c") >> >> =3D=3D=3D=3D=3DEND MWE=3D=3D=3D=3D=3D >> >> 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=3Dtable20170119 :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=3Dtable20170119 :colnames yes :results = pp > (map 'list (lambda (row) (format "%s" (nth 1 row))) table) > #+END_SRC > > #+RESULTS: > : ("1234567890" "a" "b" "c") > > HTH, > > Chuck