emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Bug: Revert orgtbl-create-or-convert-from-region [6.33x]


From: Thorsten Jolitz
Subject: Re: [O] Bug: Revert orgtbl-create-or-convert-from-region [6.33x]
Date: Mon, 05 Aug 2013 11:16:55 +0200
User-agent: Gnus/5.130002 (Ma Gnus v0.2) Emacs/24.3 (gnu/linux)

Daniel Hornung <address@hidden> writes:

> I think one great way to increase the usefulness of org-mode would be a
> function which turns a table into a csv or tsv block of text again.
>
> I assume that the functionality exists already in org-table-export, I
> would just wish for this to be exposed as a function which converts the
> table in place instead of writing it into a new file (org-table-export
> does not allow overwriting the current file).
>
> This would finally give a comfortable way to edit tsv or csv tables
> without hassles in emacs.

Would you need something more sophisticated than this?

#+TBLNAME: tbl
| header 1 | header 2 | header 3 |
|----------+----------+----------|
| label1   |        3 |       99 |
| label2   |        2 |       66 |
| label3   |        7 |      231 |
#+TBLFM: $3=$2*33

#+HEADER: :var table=tbl :hlines no
#+HEADER: :results list verbatim
#+begin_src emacs-lisp
(defun tbl2csv (table-as-lisp)
  (mapconcat
   (lambda (row)
     (mapconcat
      (lambda (cell)
         (format "%s" cell))
      row ","))
   table-as-lisp ","))

(tbl2csv table)
#+end_src

#+results:
: "header 1,header 2,header 3,label1,3,99,label2,2,66,label3,7,231"

--
cheers,
Thorsten




reply via email to

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