all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Uwe Brauer <oub@mat.ucm.es>
Cc: emacs-orgmode@gnu.org
Subject: Re: [feature] Allow "," decimal point in table cells
Date: Wed, 20 Jul 2022 21:19:11 +0800	[thread overview]
Message-ID: <87k0873os0.fsf@localhost> (raw)
In-Reply-To: <87edyg499x.fsf@mat.ucm.es>

Uwe Brauer <oub@mat.ucm.es> writes:

>> Note that you can instead use Elisp formulas. See 3.5.3 Emacs Lisp forms
>> as formulas. It is more flexible.
>
> Can you give me an example?

#+begin_src emacs-lisp
(defun yant/convert-cd (x)
  "Replace \",\" in X string with \".\" and return number."
  (string-to-number (replace-regexp-in-string "," "." x)))
(defun yant/convert-dc (x)
  "Replace \".\" in X number with \",\" and return string."
  (replace-regexp-in-string "\\." "," (format "%s" x)))
#+end_src

| 3,5 | 4,2 | 7,7 |
#+TBLFM: $3='(yant/convert-dc (apply '+ (mapcar #'yant/convert-cd (list $1 $2))))

Yes, it is awkward. Yet possible.

>> Alternatively, we may implement the comma separators as a built-in
>> feature. Org table formulas already support notations like
>
>> | 3,5 | 4,2 | 7 |
>
>> #+TBLFM: $3=$1+$2;N
>
> Not sure I understand this 
>
> | 3,5 | 4,2 | 7 | (7, 7) | (7, 7) |
> |     |     |   |        |        |
> #+TBLFM: $3=$1+$2;N::$4=$1+$2;E::$5=$1+$2;L

;N means "convert to number using string-to-number".
(string-to-number "3,5") ;; => 3
why? read the docstring (it ignores non-recognized trailing chars ",5")

L makes no sense in calc formulas (it has no effect).

E refers to dealing with empty field and has no effect here.

Best,
Ihor


  reply	other threads:[~2022-07-20 13:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-18  6:57 org-table with different conventions: decimals Uwe Brauer
2022-07-18 23:02 ` Juan Manuel Macías
2022-07-19  6:20   ` [export to CSV] (was: org-table with different conventions: decimals) Uwe Brauer
2022-07-19 11:07     ` [export to CSV] Juan Manuel Macías
2022-07-19 13:31 ` org-table with different conventions: decimals Ihor Radchenko
2022-07-19 14:39   ` Uwe Brauer
2022-07-20  3:18     ` [feature] Allow "," decimal point in table cells (was: org-table with different conventions: decimals) Ihor Radchenko
2022-07-20  5:56       ` [feature] Allow "," decimal point in table cells Uwe Brauer
2022-07-20 13:19         ` Ihor Radchenko [this message]
2022-07-20 14:00       ` [feature] Allow "," decimal point in table cells (was: org-table with different conventions: decimals) Christian Moe

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

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

  git send-email \
    --in-reply-to=87k0873os0.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=oub@mat.ucm.es \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.