From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: how to force org-mode to interpret number as string Date: Thu, 06 Mar 2014 22:34:44 -0700 Message-ID: <87k3c6vaff.fsf@gmail.com> References: <87siqx9um0.fsf@mars.lan> <871tygptqa.fsf@bzg.ath.cx> <87ha7c9xdn.fsf@mars.lan> <87lhwnug5t.fsf@gmail.com> <87r46elk95.fsf@mars.lan> 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]:39622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLnSn-0004AO-Sy for emacs-orgmode@gnu.org; Fri, 07 Mar 2014 00:36:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WLnSj-0002HD-O6 for emacs-orgmode@gnu.org; Fri, 07 Mar 2014 00:36:53 -0500 Received: from mail-pa0-x232.google.com ([2607:f8b0:400e:c03::232]:39911) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WLnSj-0002H7-Fn for emacs-orgmode@gnu.org; Fri, 07 Mar 2014 00:36:49 -0500 Received: by mail-pa0-f50.google.com with SMTP id kq14so3683549pab.23 for ; Thu, 06 Mar 2014 21:36:48 -0800 (PST) In-Reply-To: <87r46elk95.fsf@mars.lan> (Stefan Huchler's message of "Fri, 07 Mar 2014 05:12:38 +0100") 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Stefan Huchler Cc: emacs-orgmode@gnu.org >> I think that for this to work you may have to abandon using "." as your >> numerical thousands separator. Or customize string-to-number and >> org-babel-number-p to fit your number syntax. >> >> Best, > > I think the way I have to go is to use export the table to csv then it > looses some of its "cleverness" and does what it should do in the first > place. > > Hmm I just thought a second, maybe it does also do that > data-manipulation also before it exports it, but no org-table-export > does export it like a string. > > So here you have one bug, its inconsistent. > Automatically recognizing numbers in tables is useful when converting tables to code, but would make no sense for CSV export. I don't see a problem here. > > Sorry that I am maybe not so constructive but it=C2=B4s stuff that should > work and now you say that I should fix that upstream with me having > written 50 lines of lisp code in my life. > I suggested that you remove "." from your numbers. You could also wrap your numbers in "s. #+name: example | "100.00000000" | #+begin_src emacs-lisp :var example=3Dexample (caar example) #+end_src #+RESULTS: : 100.00000000 Furthermore, when I said "customize" I did not mean "fix upstream", I meant re-define org-babel-number-p in your *personal* config file. I apologize if this was not clear. > > But sorry I really flame to much, I just find some stuff really stupid, > as example why did I need to make out of a table a dict in the first > place to put it into a list with lists is really stupid, dicts are more > confortable I know in elisp maybe it has another name, but its similar > and even in python I get no list of dicts (lines). > > Is it because of monstroses big Tables and performance problems? > I would argue that the list of lists representation is indeed more commonly useful than converting a table to a list of dictionaries keyed by the header row. Maybe you will find the following helpful. #+TBLNAME: jobs | jobname | city | salary | email | | Taxi-driver | New York City | 500.000 | mayor@gotham-city.com | | Butcher | Peking | 5.000 | Jinping@china.cn | #+name: table-w-headers-to-list-of-key-value #+begin_src emacs-lisp :var data=3D'() (let ((keys (car data)) (vals (cdr data))) (mapcar (lambda (row) (map 'list #'cons keys row)) vals)) #+end_src Example usage, pull the email from each value. #+begin_src emacs-lisp :var data=3Dtable-w-headers-to-list-of-key-value(job= s) (mapcar (lambda (row) (cdr (assoc "email" row))) data) #+end_src #+RESULTS: | mayor@gotham-city.com | Jinping@china.cn | --=20 Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D