From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Loris Bennett" Subject: Re: Creating hline in table from source block? Date: Tue, 26 Nov 2013 15:23:14 +0100 Message-ID: <87zjormect.fsf@hornfels.zedat.fu-berlin.de> References: <8738mkiwhx.fsf@hornfels.zedat.fu-berlin.de> <8738mjdguk.fsf@gmail.com> <87pppnoaej.fsf@hornfels.zedat.fu-berlin.de> <878uwbmhg2.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlJY3-0007I1-Kw for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 09:23:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlJXx-0005xr-UW for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 09:23:31 -0500 Received: from plane.gmane.org ([80.91.229.3]:46499) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlJXx-0005xl-O8 for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 09:23:25 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VlJXw-00021A-BA for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 15:23:24 +0100 Received: from hornfels.zedat.fu-berlin.de ([160.45.11.110]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Nov 2013 15:23:24 +0100 Received: from loris.bennett by hornfels.zedat.fu-berlin.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 26 Nov 2013 15:23:24 +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 Eric Schulte writes: > "Loris Bennett" writes: > >> Eric Schulte writes: >> >>> "Loris Bennett" writes: >>> >>>> Dear List, >>>> >>>> This >>>> >>>> #+BEGIN_SRC sh >>>> echo "a b c d" >>>> echo "1 2 3 4" >>>> echo "5 6 7 8" >>>> #+END_SRC >>>> >>>> produces this: >>>> >>>> #+RESULTS: >>>> | a | b | c | d | >>>> | 1 | 2 | 3 | 4 | >>>> | 5 | 6 | 7 | 8 | >>>> >>>> How do I get this >>>> >>>> #+RESULTS: >>>> | a | b | c | d | >>>> |-----+---+---+---| >>>> | 1 | 2 | 3 | 4 | >>>> | 5 | 6 | 7 | 8 | >>>> >>>> ? >>>> >>> >>> Most easily done with an Emacs Lisp code block. >>> >>> #+BEGIN_SRC emacs-lisp >>> '((a b c d) >>> hline >>> (1 2 3 4) >>> (5 6 7 8)) >>> #+END_SRC >>> >>> #+RESULTS: >>> | a | b | c | d | >>> |---+---+---+---| >>> | 1 | 2 | 3 | 4 | >>> | 5 | 6 | 7 | 8 | >> >> Oops, my example was obviously a little too simple. What I am actually doing >> is something like this: >> >> #+NAME: current_data >> #+BEGIN_SRC sh :dir /home/loris/remote/far/far/away/results >> echo "step level time clicks" >> grep statistics *.log | awk '{print $(NF-9),"\t",$(NF-6),"\t",$(NF-4),"\t",$(NF-1)}' >> #+END_SRC >> > > How about > > #+NAME: current_data > #+BEGIN_SRC sh :dir /home/loris/remote/far/far/away/results :colnames '(step level time clicks) > grep statistics *.log | awk '{print $(NF-9),"\t",$(NF-6),"\t",$(NF-4),"\t",$(NF-1)}' > #+END_SRC > > or do the column names need to be generated by the code block? No, the column names are fixed, so that's perfect, thank you. I suspected there might be some more straight-forward way than the interesting, but slightly more involved methods suggested by Achim and Rasmus. However, it is good have some examples for ":results raw" and ":post" and I shall certainly be looking into "Library of Babel", as I seem to be sliding gradually into programming in Org. Cheers, Loris >> So Achim's suggestion of using ":results raw" might be the way to go >> (once I've worked out what the sed bit is doing ...) >> >> However, the table will ultimately be around 40000 lines long, >> so from a performance point of view it would be nice not to have to pipe >> the whole thing through sed, particularly as the files are on a remote >> server. Having said that though, it is not a performance-critical >> application. >> >> So maybe I'll look at Rasmus' simpler suggestion (my lisp skill are >> unfortunately not quite up to the "fun" variant ...) >> >> How complex would the elisp version of my grep and awk above be? Just >> having one code block would be a little neater from my point of view. >> >> Thanks for all the help. >> >> Cheers, >> >> Loris -- Dr. Loris Bennett (Mr.) ZEDAT, Freie Universität Berlin Email loris.bennett@fu-berlin.de