emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org-table with different conventions: decimals
@ 2022-07-18  6:57 Uwe Brauer
  2022-07-18 23:02 ` Juan Manuel Macías
  2022-07-19 13:31 ` org-table with different conventions: decimals Ihor Radchenko
  0 siblings, 2 replies; 10+ messages in thread
From: Uwe Brauer @ 2022-07-18  6:57 UTC (permalink / raw)
  To: emacs-orgmode



Hi

In my current setting, the following works

| 3.5 | 4.2 | 7.7 |
#+TBLFM: $3=$1+$2

Now if I want to switch to the convention used in Germany (that might be
relevant if I want to export it later to csv, but this is a different
topic) does work in a strange way, any comments? I would expect

| 3,5 | 4,2 | (7, 7) |
#+TBLFM: $3=$1+$2


| 3,5 | 4,2 | 7,7    |
#+TBLFM: $3=$1+$2


-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: org-table with different conventions: decimals
  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 13:31 ` org-table with different conventions: decimals Ihor Radchenko
  1 sibling, 1 reply; 10+ messages in thread
From: Juan Manuel Macías @ 2022-07-18 23:02 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: orgmode

Uwe Brauer writes:

> Now if I want to switch to the convention used in Germany (that might be
> relevant if I want to export it later to csv, but this is a different
> topic) does work in a strange way, any comments? [...]

Hi, Uwe,

If you only need to export to LaTeX you can load the siunitx package,
which not only fits the decimals perfectly in a table but you can also
define a value for the decimal sign that will be seen in the PDF.

It has a small drawback. Columns with numeric value (S) cannot contain
anything other than numbers. If you want to add an arbitrary text string
in one of those columns you must enclose that string in {}. That is, on
the org side it would be @@latex:{foo}@@

You can try this with your example:

#+LaTeX_Header: \usepackage{siunitx}
#+LaTeX_Header: \sisetup{detect-all}
#+LaTeX_Header: \sisetup{output-decimal-marker = {,}}

#+ATTR_LaTeX: :align SSS
| 3.5 | 4.2 | 7.7 |
#+TBLFM: $3=$1+$2

Best regards,

Juan Manuel 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [export to CSV] (was: org-table with different conventions: decimals)
  2022-07-18 23:02 ` Juan Manuel Macías
@ 2022-07-19  6:20   ` Uwe Brauer
  2022-07-19 11:07     ` [export to CSV] Juan Manuel Macías
  0 siblings, 1 reply; 10+ messages in thread
From: Uwe Brauer @ 2022-07-19  6:20 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]

>>> "JMM" == Juan Manuel Macías <maciaschain@posteo.net> writes:

Hi Juan Manuel


> Uwe Brauer writes:
>> Now if I want to switch to the convention used in Germany (that might be
>> relevant if I want to export it later to csv, but this is a different
>> topic) does work in a strange way, any comments? [...]

> Hi, Uwe,

> If you only need to export to LaTeX you can load the siunitx package,
> which not only fits the decimals perfectly in a table but you can also
> define a value for the decimal sign that will be seen in the PDF.

Thanks but I don't want to export the table to latex, instead I want to
export it to CSV and later import it into Scalc (LO).

So I think the correct way of dealing with this situation is not export
it with english convention to csv and then in Scalc set the default
language to German and import the csv as English (US).

That is a bit cumbersome, but doable.

Regards (take care with the heat if you live in Spain (not sure though))

Uwe 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [export to CSV]
  2022-07-19  6:20   ` [export to CSV] (was: org-table with different conventions: decimals) Uwe Brauer
@ 2022-07-19 11:07     ` Juan Manuel Macías
  0 siblings, 0 replies; 10+ messages in thread
From: Juan Manuel Macías @ 2022-07-19 11:07 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: orgmode

Uwe Brauer writes:

> Regards (take care with the heat if you live in Spain (not sure though))

Yes, I live in the Sierra de Madrid, where we are always a few degrees
below Madrid, and these days this is an oven. I guess that you are also
in Spain, because of the mail from the UCM. If so, take care too :-).
Although I think that these days few places in Europe are safe...

Best regards,

Juan Manuel 



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: org-table with different conventions: decimals
  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 13:31 ` Ihor Radchenko
  2022-07-19 14:39   ` Uwe Brauer
  1 sibling, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2022-07-19 13:31 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-orgmode

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

> In my current setting, the following works
>
> | 3.5 | 4.2 | 7.7 |
> #+TBLFM: $3=$1+$2
>
> Now if I want to switch to the convention used in Germany (that might be
> relevant if I want to export it later to csv, but this is a different
> topic) does work in a strange way, any comments? I would expect
>
> | 3,5 | 4,2 | (7, 7) |
> #+TBLFM: $3=$1+$2
>
>
> | 3,5 | 4,2 | 7,7    |
> #+TBLFM: $3=$1+$2

Org tables use Emacs' calc under the hood by default.
AFAIK, calc is unable to use "," as decimal point because it is reserved
as a vector separator. Which is why you got the vector addition in your
example.

Best,
Ihor


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: org-table with different conventions: decimals
  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
  0 siblings, 1 reply; 10+ messages in thread
From: Uwe Brauer @ 2022-07-19 14:39 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 562 bytes --]


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

> Org tables use Emacs' calc under the hood by default.
> AFAIK, calc is unable to use "," as decimal point because it is reserved
> as a vector separator. Which is why you got the vector addition in your
> example.

Thanks. I was afraid that the issue was with calc not with org-mode.

Uwe 



-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 

[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [feature] Allow "," decimal point in table cells (was: org-table with different conventions: decimals)
  2022-07-19 14:39   ` Uwe Brauer
@ 2022-07-20  3:18     ` Ihor Radchenko
  2022-07-20  5:56       ` [feature] Allow "," decimal point in table cells Uwe Brauer
  2022-07-20 14:00       ` [feature] Allow "," decimal point in table cells (was: org-table with different conventions: decimals) Christian Moe
  0 siblings, 2 replies; 10+ messages in thread
From: Ihor Radchenko @ 2022-07-20  3:18 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-orgmode

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

>> Uwe Brauer <oub@mat.ucm.es> writes:
>
>> Org tables use Emacs' calc under the hood by default.
>> AFAIK, calc is unable to use "," as decimal point because it is reserved
>> as a vector separator. Which is why you got the vector addition in your
>> example.
>
> Thanks. I was afraid that the issue was with calc not with org-mode.

Note that you can instead use Elisp formulas. See 3.5.3 Emacs Lisp forms
as formulas. It is more flexible.

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

or

#+TBLFM: $3=$1+$2;E
#+TBLFM: $3=$1+$2;L

(see 3.5.2 Formula syntax for Calc)

we may as well implement something like ";Nc" that will interpret cells
as numbers with "," as decimal point separator.

Is there such a demand?

Best,
Ihor


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [feature] Allow "," decimal point in table cells
  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       ` Uwe Brauer
  2022-07-20 13:19         ` Ihor Radchenko
  2022-07-20 14:00       ` [feature] Allow "," decimal point in table cells (was: org-table with different conventions: decimals) Christian Moe
  1 sibling, 1 reply; 10+ messages in thread
From: Uwe Brauer @ 2022-07-20  5:56 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1894 bytes --]

>>> "IR" == Ihor Radchenko <yantar92@gmail.com> writes:

> Uwe Brauer <oub@mat.ucm.es> writes:
>>> Uwe Brauer <oub@mat.ucm.es> writes:
>> 
>>> Org tables use Emacs' calc under the hood by default.
>>> AFAIK, calc is unable to use "," as decimal point because it is reserved
>>> as a vector separator. Which is why you got the vector addition in your
>>> example.
>> 
>> Thanks. I was afraid that the issue was with calc not with org-mode.

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

> 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

> (see 3.5.2 Formula syntax for Calc)

> we may as well implement something like ";Nc" that will interpret cells
> as numbers with "," as decimal point separator.

> Is there such a demand?

> (see 3.5.2 Formula syntax for Calc)

> we may as well implement something like ";Nc" that will interpret cells
> as numbers with "," as decimal point separator.

> Is there such a demand?

I think others should speak up, all I can say

    1. «,» is the standard in German speaking countries, while

    2. «'» is the standard in Spanish speaking countries 

For the separator.

In my use case  I need to generate  ods documents that use the
German language setting, org-mode however relying on calc needs the
notation that the «.» Separate digits while in German it is the «,».

I solve this issue by exporting my org-table to csv, set scalc to German
as a default language, and then import the csv file, using American
English.


[-- Attachment #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5673 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [feature] Allow "," decimal point in table cells
  2022-07-20  5:56       ` [feature] Allow "," decimal point in table cells Uwe Brauer
@ 2022-07-20 13:19         ` Ihor Radchenko
  0 siblings, 0 replies; 10+ messages in thread
From: Ihor Radchenko @ 2022-07-20 13:19 UTC (permalink / raw)
  To: Uwe Brauer; +Cc: emacs-orgmode

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [feature] Allow "," decimal point in table cells (was: org-table with different conventions: decimals)
  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 14:00       ` Christian Moe
  1 sibling, 0 replies; 10+ messages in thread
From: Christian Moe @ 2022-07-20 14:00 UTC (permalink / raw)
  To: emacs-orgmode


Ihor Radchenko writes:

> Uwe Brauer <oub@mat.ucm.es> writes:
>
>>> Uwe Brauer <oub@mat.ucm.es> writes:
>>
>>> Org tables use Emacs' calc under the hood by default.
>>> AFAIK, calc is unable to use "," as decimal point because it is reserved
>>> as a vector separator. Which is why you got the vector addition in your
>>> example.
>>
>> Thanks. I was afraid that the issue was with calc not with org-mode.
>
> Note that you can instead use Elisp formulas. See 3.5.3 Emacs Lisp forms
> as formulas. It is more flexible.
>
> 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
>
> or
>
> #+TBLFM: $3=$1+$2;E
> #+TBLFM: $3=$1+$2;L
>
> (see 3.5.2 Formula syntax for Calc)
>
> we may as well implement something like ";Nc" that will interpret cells
> as numbers with "," as decimal point separator.
>
> Is there such a demand?
>
> Best,
> Ihor

That's interesting.

I remember an earlier discussion that settled on the recommendation to
keep the spreadsheet as it is and use export-hooks if one needs to
change the decimal separator upon export. My contribution to the
discussion also gave Carsten the idea of starting a Worg page called
org-madness.org. :-).

Thread started here:
https://lists.gnu.org/archive/html/emacs-orgmode/2011-05/msg00551.html

But I don't think we considered the possibility of a flag to make Org
translate dot-separated decimals into comma-separated ones for
Calc. That could offer more fine-grained control than export processing
when you need some dots to stay dots. And it would certainly be less
challenging for users who just want things to work without digging into
advanced export options!

Export processing (which has since become more fine-grained with the
introduction of filters) remains an option, though, and some backends
offer further possibilities.

Yours,
Christian


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-07-20 14:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-07-20 14:00       ` [feature] Allow "," decimal point in table cells (was: org-table with different conventions: decimals) Christian Moe

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