From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: tables: is it possible to use a comma instead of a period as a number delimiter Date: Mon, 16 May 2011 14:20:16 +0200 Message-ID: <10592E39-3950-406F-ABBF-02525560AEB5@gmail.com> References: <4DD109FE.7090207@christianmoe.com> Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:38031) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QLwmc-0000xB-36 for emacs-orgmode@gnu.org; Mon, 16 May 2011 08:20:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QLwma-0000k4-KN for emacs-orgmode@gnu.org; Mon, 16 May 2011 08:20:22 -0400 Received: from mail-ew0-f41.google.com ([209.85.215.41]:43303) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QLwma-0000ju-Bw for emacs-orgmode@gnu.org; Mon, 16 May 2011 08:20:20 -0400 Received: by ewy9 with SMTP id 9so1457529ewy.0 for ; Mon, 16 May 2011 05:20:19 -0700 (PDT) In-Reply-To: <4DD109FE.7090207@christianmoe.com> 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: mail@christianmoe.com Cc: Michael Brand , emacs-orgmode@gnu.org, Izzie On May 16, 2011, at 1:26 PM, Christian Moe wrote: > Hi, >=20 > This seems to be a limitation in Emacs Calc, on which Org table = spreadsheet functions are based. Calc accepts only the dot as decimal = point for number *entry*. However, you can have it *display* the point = as you like by customizing calc-point-char (that's `d .' in a Calc = buffer). >=20 > In Org, you *could* try this: >=20 > (setq org-calc-default-modes > (append org-calc-default-modes '(calc-point-char ","))) >=20 > However, it looks like this creates more problems than it's worth. = Commas remain useless for data entry, including entry from Org table = cells, so you would need to keep a source column with dots, and copy the = numbers over to the column you want to display. And you could only do = math on the source column. E. g., the following would work for a column = of numbers to be summed at the bottom line: >=20 > | Point | Comma | > |-------+-------| > | 2.3 | | > | 11.3 | | > | 2.1 | | > |-------+-------| > | | | > #+TBLFM: $2=3D$1+0::@5$2=3Dvsum(@I$1..@II$1) >=20 > ... But would you want to do this? Probably not. So something like = Michael's solution seems to be the best option. Or are we missing = something here? >=20 > This is not unlike the hour-minutes-seconds time format hack we = discussed a while ago. >=20 > http://orgmode.org/worg/org-hacks.html#time-computation >=20 > Org tables with Calc is the greatest invention since buttered toast, = but user-friendly localizable formats for non-scientific uses may not be = its strong side. I also think that it would be more trouble than useful to try to change this. After all, you want to keep the tables functional. When the OP says he needs this for accounting, I guess he is exporting this data somehow? How about changing from dot to comma only in one of the export hooks? (add-hook 'org-export-preprocess-hook 'org-use-comma-in-exported-tables) (defun org-use-comma-in-exported-tables () (goto-char (point-min)) (while (re-search-forward "\\([0-9]\\)\\.\\([0-9]\\)" nil t) (org-if-unprotected (when (save-match-data (org-at-table-p)) (replace-match "\\1,\\2" t nil))))) - Carsten >=20 > Yours, > Christian >=20 >=20 > On 5/16/11 12:05 PM, Michael Brand wrote: >> Hi Izzie >>=20 >> The only direct solution I can think of now is with Emacs Lisp for >> number/string conversion and ./, replacement: >>=20 >> #+begin_src emacs-lisp :results silent >> (defun com2num (com) >> "convert number string with comma like \"2,3\" to number like = 2.3" >> (string-to-number (replace-regexp-in-string "," "." com))) >> (defun num2com (fmt num) >> "convert number like 2.300001 to number string with comma >> like \"2,3\", formatted with fmt like \"%.1f\"" >> (replace-regexp-in-string "\\." "," (format fmt num))) >> #+end_src >>=20 >> | | >> |------| >> | 10,2 | >> | 3,0 | >> | 5,6 | >> |------| >> | 18,8 | >> #+TBLFM: @5=3D'(num2com "%.1f" (apply '+ (mapcar 'com2num = '(@2..@4)))) >>=20 >> Michael >>=20 >> On Mon, May 16, 2011 at 01:12, Izzie = wrote: >>> I started using org tables including a column of numbers formatted = the European >>> way with a comma instead of a period, for example 127,43 for 127.43. >>>=20 >>> When I use a formula to sum the whole column it expect a period and = ends up with >>> a false calculation. I'd revert my numbers to the American format = but this table >>> is used for accounting so it's not an option. Going through the = manual didn't >>> provide any help. >>>=20 >>> Is there a way to have org use the european format or am I to ditch = the formula >>> and make use of C-c + to manually calculate the sum ? >>=20 >>=20 >=20 >=20 - Carsten