emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Creating hline in table from source block?


From: Loris Bennett
Subject: Re: [O] Creating hline in table from source block?
Date: Tue, 26 Nov 2013 15:23:14 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)

Eric Schulte <address@hidden> writes:

> "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?

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 address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]