[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] Creating hline in table from source block?
From: |
Eric Schulte |
Subject: |
Re: [O] Creating hline in table from source block? |
Date: |
Tue, 26 Nov 2013 06:14:23 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
"Loris Bennett" <address@hidden> writes:
> Eric Schulte <address@hidden> writes:
>
>> "Loris Bennett" <address@hidden> 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