emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Achim Gratz <Stromeko@nexgo.de>
To: emacs-orgmode@gnu.org
Subject: Re: simple script to convert txt tables to Org-mode tables on the command line
Date: Mon, 07 Jan 2013 21:33:39 +0100	[thread overview]
Message-ID: <87a9skravw.fsf@Rainer.invalid> (raw)
In-Reply-To: 87bod069gs.fsf@bzg.ath.cx

Bastien writes:
> In the same vein, the next release of Clojure (1.5) includes
> a way to export to Org mode tables:

While we are talking about exporting tables to/from Org: Start a session
from sudoku.el and use this org file to easily import Sudoku from a
paper or book into sudoku.el and maybe keep track of what you did.  Not
the most elegant code for dealing with the lists structures, but it gets
the job done.

--8<---------------cut here---------------start------------->8---
#+NAME: export-sudoku
#+BEGIN_SRC emacs-lisp :var table=() :hlines no :results output silent
  (setq custom-puzzles 
        (list
         (mapcar
          (lambda (row)
            (mapcar
             (lambda (entry)
               (if (stringp entry) 0 entry))
             row))
          (remove 'hline table))))
#+END_SRC
#+NAME: import-sudoku
#+BEGIN_SRC emacs-lisp :results value :hlines yes
  (let (board
        (index 0))
  (setq board (mapcar
               (lambda (row)
                 (mapcar
                  (lambda (entry)
                    (if (zerop entry) "" entry))
                  row))
               current-board))
  (list
   (nth 0 board) (nth 1 board) (nth 2 board)
   'hline
   (nth 3 board) (nth 4 board) (nth 5 board)
   'hline
   (nth 6 board) (nth 7 board) (nth 8 board)))
#+END_SRC

#+TBLNAME: Test
| 3 |   | 2 |   |   |   | 5 |   | 8 |
|   | 9 |   | 3 |   | 5 |   | 6 |   |
| 6 |   |   |   | 7 |   |   |   | 4 |
|---+---+---+---+---+---+---+---+---|
|   | 8 |   | 1 |   | 4 |   | 2 |   |
|   |   | 9 |   |   |   | 8 |   |   |
|   | 2 |   | 6 |   | 9 |   | 5 |   |
|---+---+---+---+---+---+---+---+---|
| 8 |   |   |   | 9 |   |   |   | 5 |
|   | 1 |   | 4 |   | 3 |   | 8 |   |
| 2 |   | 4 |   |   |   | 1 |   | 9 |
#+CALL: export-sudoku(table=Test) :results output silent
#+CALL: import-sudoku() :hlines yes
--8<---------------cut here---------------end--------------->8---

One noteworthy thing: even though I say ":hlines no" (I can also do this
on the call line with the same result), the table still gets exported to
elisp _with_ hlines and I need to filter them out myself.  I'm not sure
if that is intended, but it feels a bit awkward.  If anything, this
exception should be noted in the documentation if it is intentional.


Regards,
Achim.
-- 
+<[Q+ Matrix-12 WAVE#46+305 Neuron microQkb Andromeda XTk Blofeld]>+

Factory and User Sound Singles for Waldorf Blofeld:
http://Synth.Stromeko.net/Downloads.html#WaldorfSounds

  reply	other threads:[~2013-01-07 20:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-07 18:27 simple script to convert txt tables to Org-mode tables on the command line Eric Schulte
2013-01-07 18:37 ` Jambunathan K
2013-01-07 18:48   ` Eric Schulte
2013-01-07 18:54 ` Nick Dokos
2013-01-07 20:09 ` Bastien
2013-01-07 20:33   ` Achim Gratz [this message]
2013-01-07 20:54     ` Eric Schulte
2013-01-07 21:36       ` Achim Gratz
2013-01-08  6:38         ` Eric Schulte
2013-01-08 18:55           ` Achim Gratz
2013-01-09 17:22             ` Eric Schulte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a9skravw.fsf@Rainer.invalid \
    --to=stromeko@nexgo.de \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).