emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] how to force org-mode to interpret number as string


From: Eric Schulte
Subject: Re: [O] how to force org-mode to interpret number as string
Date: Thu, 06 Mar 2014 22:34:44 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

>> 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 | address@hidden |
| Butcher     | Peking        |   5.000 | address@hidden      |

#+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:
| address@hidden | address@hidden |

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]