From mboxrd@z Thu Jan 1 00:00:00 1970 From: Achim Gratz 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 Message-ID: <87a9skravw.fsf@Rainer.invalid> References: <87a9skalwy.fsf@gmail.com> <87bod069gs.fsf@bzg.ath.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:54407) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsJOS-0004f4-Sh for emacs-orgmode@gnu.org; Mon, 07 Jan 2013 15:34:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TsJOR-0004Ke-He for emacs-orgmode@gnu.org; Mon, 07 Jan 2013 15:34:00 -0500 Received: from plane.gmane.org ([80.91.229.3]:43521) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TsJOR-0004KY-Af for emacs-orgmode@gnu.org; Mon, 07 Jan 2013 15:33:59 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1TsJOc-0004H5-Ll for emacs-orgmode@gnu.org; Mon, 07 Jan 2013 21:34:10 +0100 Received: from pd9eb23fe.dip.t-dialin.net ([217.235.35.254]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Jan 2013 21:34:10 +0100 Received: from Stromeko by pd9eb23fe.dip.t-dialin.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Mon, 07 Jan 2013 21:34:10 +0100 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org 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