[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [PATCH] Process hlines in imported tables
From: |
Eric Schulte |
Subject: |
Re: [O] [PATCH] Process hlines in imported tables |
Date: |
Sat, 30 Mar 2013 18:43:30 -0600 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
Rick Frankel <address@hidden> writes:
> On Fri, Mar 29, 2013 at 06:01:21PM -0600, Eric Schulte wrote:
>> > Yes and no. :colnames works, but often the header comes from the
>> > processing, so they may not be static (I use a lot of call:s). Also,
>> > I've been having trouble using the output from raw results as input --
>> > it seems that unless the results are cached (:cache yes), the table is
>> > not parsed on input, but passed as a multiline string. I was hoping to
>> > avoid this problem using value returns (now that Achim has made the
>> > perl parsing work better). Here's an example (btw, this breaks in 7.4
>> > as well):
>> >
>>
>> Alright, I've just pushed up changes so that org and wrap results will
>> expand tables (not just raw). With this change in place you can now use
>> ":results wrap" to get the results you want, and since they are
>> delimited, you can then re-use these results in later code blocks.
>>
>
> Better for the elisp. But perl table processing is now totally wacky:
>
> *Note* =wrap= and =raw= give same results
> #+begin_src perl :results raw
> q[|c1|c2|
> |-
> |a|1|
> |b|2|];
> #+end_src
>
> #+results:
> | | c1 | c2 |
> | | - | |
> | | a | 1 |
> | | b | 2 |
>
This is a problem in the results returned by ob-perl, not in the results
insertion mechanism. Given what is actually being returned by that code
block the results make sense.
#+name: perl-example
#+begin_src perl :results raw
q[|c1|c2|
|-
|a|1|
|b|2|];
#+end_src
#+begin_src emacs-lisp :var data=perl-example :results verbatim
(format "%S" data)
#+end_src
#+RESULTS:
: "((\"\" \"c1\" \"c2\") (\"\" \"-\" \"\") (\"\" \"a\" 1) (\"\" \"b\" 2))"
If we add verbatim (which inhibits interpretation as a value, which can
often result in a list or table result), then we get what I assume you
expect.
#+name: perl-example
#+begin_src perl :results verbatim raw
q[|c1|c2|
|-
|a|1|
|b|2|];
#+end_src
#+RESULTS: perl-example
| c1 | c2 |
|----+----|
| a | 1 |
| b | 2 |
>
> #+begin_src perl :results raw
> q[c1|c2
> -
> a|1
> b|2];
> #+end_src
>
> #+results:
> | c1 | c2 |
> | - | |
> | a | 1 |
> | b | 2 |
>
This output above makes sense. Maybe try the following (with verbatim)
instead.
#+begin_src perl :results verbatim drawer
q[|c1|c2
|-
|a|1
|b|2];
#+end_src
#+results:
:RESULTS:
| c1 | c2 |
|----+----|
| a | 1 |
| b | 2 |
:END:
>
> #+begin_src perl :results raw output
> print q[|c1|c2|
> |-
> |a|1|
> |b|2|
> ];
> #+end_src
>
> #+results:
> | c1 | c2 |
> |----+----|
> | a | 1 |
> | b | 2 |
>
This one looks good to me as is. I added a note about verbatim to [1],
if you can think anything else from this discussion that could be of
general interest please place it there as well.
Thanks,
Footnotes:
[1] http://orgmode.org/worg/org-contrib/babel/header-args.html
--
Eric Schulte
http://cs.unm.edu/~eschulte