[Top][All Lists]

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

Re: [O] tables: is it possible to use a comma instead of a period as a n

From: Christian Moe
Subject: Re: [O] tables: is it possible to use a comma instead of a period as a number delimiter
Date: Mon, 16 May 2011 13:26:54 +0200
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv: Gecko/20110414 Thunderbird/3.1.10


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).

In Org, you *could* try this:

(setq org-calc-default-modes
      (append org-calc-default-modes '(calc-point-char ",")))

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:

| Point | Comma |
|   2.3 |       |
|  11.3 |       |
|   2.1 |       |
|       |       |
#+TBLFM: $2=$1+0::@5$2=vsum(@address@hidden)

... 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?

This is not unlike the hour-minutes-seconds time format hack we discussed a while ago.


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.


On 5/16/11 12:05 PM, Michael Brand wrote:
Hi Izzie

The only direct solution I can think of now is with Emacs Lisp for
number/string conversion and ./, replacement:

#+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)))

|<r>  |
| 10,2 |
|  3,0 |
|  5,6 |
| 18,8 |
#+TBLFM: @5='(num2com "%.1f" (apply '+ (mapcar 'com2num '(@address@hidden))))


On Mon, May 16, 2011 at 01:12, Izzie<address@hidden>  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.

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.

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 ?

reply via email to

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