[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Strings converted to numbers in Org table?
From: |
Vicente Vera |
Subject: |
Re: [O] Strings converted to numbers in Org table? |
Date: |
Mon, 27 Feb 2017 15:31:58 +0000 |
Hello again, I'm sorry for being noisy.
OK yes, `org-babel-read' is indeed converting "number strings" to
numbers.
Basically this is what happens:
: (string-to-number "3.350") => 3.35
To leave cell values unchanged I did this clumsy hack:
#+BEGIN_SRC emacs-lisp
(defun test-other-org-babel-read (cell &optional inhibit-lisp-eval)
(if (and (stringp cell) (not (equal cell "")))
;; ;; (or (org-babel--string-to-number cell)
(if (and (not inhibit-lisp-eval)
(or (member (substring cell 0 1) '("(" "'" "`" "["))
(string= cell "*this*")))
(eval (read cell) t)
(if (string= (substring cell 0 1) "\"")
(read cell)
(progn (set-text-properties 0 (length cell) nil cell) cell)))
;; ;; )
cell))
;; Override default behavior
(fset 'org-babel-read 'test-other-org-babel-read)
#+END_SRC
It would be useful to have a header argument to prevent this
conversion. Probably somebody else has had the same issue?