emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Stefan Huchler <stefan.huchler@mail.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: how to force org-mode to interpret number as string
Date: Thu, 06 Mar 2014 22:34:44 -0700	[thread overview]
Message-ID: <87k3c6vaff.fsf@gmail.com> (raw)
In-Reply-To: <87r46elk95.fsf@mars.lan> (Stefan Huchler's message of "Fri, 07 Mar 2014 05:12:38 +0100")

>> 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´s 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=example
(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='()
  (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=table-w-headers-to-list-of-key-value(jobs)
(mapcar (lambda (row) (cdr (assoc "email" row))) data)
#+end_src

#+RESULTS:
| mayor@gotham-city.com | Jinping@china.cn |

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

  reply	other threads:[~2014-03-07  5:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-05  3:45 how to force org-mode to interpret number as string Stefan Huchler
2014-03-05 15:09 ` Bastien
2014-03-05 21:06   ` Stefan Huchler
2014-03-06 17:14     ` Eric Schulte
2014-03-07  4:12       ` Stefan Huchler
2014-03-07  5:34         ` Eric Schulte [this message]
2014-03-07 14:10           ` Stefan Huchler
2014-03-13 14:37             ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k3c6vaff.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=stefan.huchler@mail.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).