From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [PATCH] Process hlines in imported tables Date: Sat, 30 Mar 2013 18:43:30 -0600 Message-ID: <87mwtkqtzh.fsf@gmail.com> References: <20130329014615.GA49671@BigDog.local> <87wqsq6yd1.fsf@gmail.com> <20130329214238.GA53401@BigDog.local> <87r4ixah7y.fsf@gmail.com> <20130330234151.GA53721@BigDog.local> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([208.118.235.92]:60344) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UM6NB-0003Nj-1r for emacs-orgmode@gnu.org; Sat, 30 Mar 2013 20:43:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UM6N9-0004im-2n for emacs-orgmode@gnu.org; Sat, 30 Mar 2013 20:43:49 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:63982) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UM6N8-0004ig-Sh for emacs-orgmode@gnu.org; Sat, 30 Mar 2013 20:43:46 -0400 Received: by mail-pa0-f54.google.com with SMTP id fa10so817259pad.41 for ; Sat, 30 Mar 2013 17:43:46 -0700 (PDT) In-Reply-To: <20130330234151.GA53721@BigDog.local> (Rick Frankel's message of "Sat, 30 Mar 2013 19:41:51 -0400") 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 Rick Frankel 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