From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: Creating hline in table from source block? Date: Tue, 26 Nov 2013 06:14:23 -0700 Message-ID: <878uwbmhg2.fsf@gmail.com> References: <8738mkiwhx.fsf@hornfels.zedat.fu-berlin.de> <8738mjdguk.fsf@gmail.com> <87pppnoaej.fsf@hornfels.zedat.fu-berlin.de> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52552) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlIWM-000715-Kw for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 08:17:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VlIWG-0001fy-Mk for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 08:17:42 -0500 Received: from mail-pd0-x229.google.com ([2607:f8b0:400e:c02::229]:44008) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VlIWG-0001fn-FA for emacs-orgmode@gnu.org; Tue, 26 Nov 2013 08:17:36 -0500 Received: by mail-pd0-f169.google.com with SMTP id v10so7686316pde.0 for ; Tue, 26 Nov 2013 05:17:35 -0800 (PST) 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: Loris Bennett Cc: emacs-orgmode@gnu.org "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? > > 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 -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D