From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: Trouble with Tables and Python Date: Tue, 15 Apr 2014 21:29:41 -0400 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b163827c145a204f71ed9a6 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WaEfZ-0006xk-2U for emacs-orgmode@gnu.org; Tue, 15 Apr 2014 21:29:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WaEfX-0008LI-Hp for emacs-orgmode@gnu.org; Tue, 15 Apr 2014 21:29:45 -0400 Received: from mail-pd0-x22f.google.com ([2607:f8b0:400e:c02::22f]:54203) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WaEfX-0008LC-6v for emacs-orgmode@gnu.org; Tue, 15 Apr 2014 21:29:43 -0400 Received: by mail-pd0-f175.google.com with SMTP id x10so10108169pdj.20 for ; Tue, 15 Apr 2014 18:29:41 -0700 (PDT) In-Reply-To: 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: =?UTF-8?B?TWFydGluIFNjaMO2w7Zu?= Cc: "emacs-orgmode@gnu.org" --047d7b163827c145a204f71ed9a6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I should probably confess to having this in my .emacs files: ;; language specific headers. I think this comes before the defaults (setq org-babel-default-header-args:emacs-lisp (cons '(:results . "value replace") (assq-delete-all :results org-babel-default-header-args))) ;; set default :results to output (setq org-babel-default-header-args (cons '(:results . "output replace") (assq-delete-all :results org-babel-default-header-args))) ;; set default exports to both code and results (setq org-babel-default-header-args (cons '(:exports . "both") (assq-delete-all :exports org-babel-default-header-args))) These things change the default behaviors for the results. I almost always want output as results, and not value (the regular default), except when coding in emacs-lisp where the value make sense to me. That would certainly be a point of confusion ;) I also find you want :results output raw if you are printing a table or printing org. This is something I have never found satisfying, especially for long tables or outputs it is tedious to have to delete the old output by hand before rerunning it. I have not found any other sets of options that do what I want, e.g. changing raw to org results in the section being wrapped in #+begin_org/end_org, which is usually not what I want. I usually do want the raw output. I hope that clarifies where some of your differences might be coming from. John ----------------------------------- John Kitchin Associate Professor Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 http://kitchingroup.cheme.cmu.edu On Tue, Apr 15, 2014 at 5:18 PM, Martin Sch=C3=B6=C3=B6n wrote: > This is my first post here... > > I have been using org-mode as a pure TODO-tool for some time but this > winter I realised it could be used for much more and I have been > experimenting with mixing in LaTeX and Python for fun and because I find > literate programming a particularly sane idea (I am a HW engineer). > > Less than I week ago I started to look into using tables for input and > output to/from Python scripts. I was inspired by something I found at > http://kitchingroup.cheme.cmu.edu/ . The enclosed example 1 file is a > pruned version of the org-file I found there. If I run the embedded Pytho= n > script using C-c C-c I don't get the table shown in the example. Instead = I > get "none" on the row following "#+RESULTS:" > > If I change ":results raw" to ":results output" I do get the table but > 'wrapped' in "#+begin_example" and "#+end_example" as shown in the > enclosed example 2 file. I have done some further testing/changes in that > file (adding some stuff to the top of the file and changing the formattin= g > of the print statements) none of which changed the extra wrapping of the > table. When I export to LaTeX -> PDF the table does not show up in the > end result. > > Let's move over to the third example file and the real mystery. This all > my own code. Reading data from the first table works just fine and the sa= me > goes for the calculations. The output table, however, is different from > that of example 2. The 'wrapper' is gone but each row is starting with ": > ". Where does that come from? Why does it differ from example 2? If my > results differ from someone else's (different install/versions etc) -- > OK. But how can I get differences like this on my own? To my un-trained > eyes the print statements of examples 2 and 3 look very similar. (But, th= e > first things that go blind are the eyes... probably something blatantly > obvious once pointed out to me.) > > OS: #! Linux (Based on Debian stable, 64-bit) > Emacs: 23.4.1 > Org-mode: 8.2.5h > Python: 2.7.3 > > TIA, > -- > Martin Sch=C3=B6=C3=B6n > > http://hem.bredband.net/b262106/index.html > --047d7b163827c145a204f71ed9a6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I should probably confess to havi= ng this in my .emacs files:

;; language specific headers. I think th= is comes before the defaults
(setq org-babel-default-header-args:emacs-l= isp
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (cons '(:results . "value replace&q= uot;)
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (assq-delete-all :results or= g-babel-default-header-args)))

;; set default :results to output
= (setq org-babel-default-header-args
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (cons= '(:results . "output replace")
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 (assq-delete-all :results org-babel-d= efault-header-args)))

;; set default exports to both code and result= s
(setq org-babel-default-header-args
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = (cons '(:exports . "both")
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0= =C2=A0 (assq-delete-all :exports org-babel-default-header-args)))

These things change the default behaviors for the results. I almo= st always want output as results, and not value (the regular default), exce= pt when coding in emacs-lisp where the value make sense to me.

That would certainly be a point of confusion ;)

I also find yo= u want :results output raw

if you are printing a table or prin= ting org. This is something I have never found satisfying, especially for l= ong tables or outputs it is tedious to have to delete the old output by han= d before rerunning it. I have not found any other sets of options that do w= hat I want, e.g. changing raw to org results in the section being wrapped i= n #+begin_org/end_org, which is usually not what I want. I usually do want = the raw output.

I hope that clarifies where some of your differences might be com= ing from.

John
-----------------------------------
John Kitchin
Associate Prof= essor
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon= University
Pittsburgh, PA 15213
412-268-7803
http://kitchingroup.cheme.cmu.e= du



On Tue, Apr 15, 2014 at 5:18 PM, Martin = Sch=C3=B6=C3=B6n <martin.schoon@gmail.com> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px= #ccc solid;padding-left:1ex">
This is my f= irst post here...

I have been using org-mode as a= pure TODO-tool for some time but this winter I realised it co= uld be used for much more and I have been experimenting with mixing in LaTeX and Python for fun and because I find literate programming a= particularly sane idea (I am a HW engineer).

Less than I week ago I started to look into using ta= bles for input and output to/from Python scripts. I was inspired by somethi= ng I found at http://kitchingroup.cheme.cmu= .edu/ . The enclosed example 1 file is a pruned version= of the org-file I found there. If I run the embedded Python script using C= -c C-c I don't get the table shown in the example. Instead I get "= none" on the row following "#+RESULTS:"

If I change ":results raw" to ":resul= ts output" I do get the table but 'wrapped' in "#+begin_e= xample" and "#+end_example" as shown in=C2=A0 the enclosed e= xample 2 file. I have done some further testing/changes in that file (addin= g some stuff to the top of the file and changing the formatting of the prin= t statements) none of which changed the extra wrapping of the table. When I= export to LaTeX -> PDF the table does not sho= w up in the end result.

Let's move over to the third example file and th= e real mystery. This all my own code. Reading data from the first table wor= ks just fine and the same goes for the calculations. The output table, howe= ver, is different from that of example 2. The 'wrapper' is gone but= each row is starting with ": ". Where does that come from? Why d= oes it differ from example 2? If my results differ from someone else&= #39;s (different install/versions etc) -- OK. But how can I get diff= erences like this on my own? To my=C2=A0 un-trained eyes the p= rint statements of examples 2 and 3 look very similar. (But, the first thin= gs that go blind are the eyes... probably something blatantly = obvious once pointed out to me.)

OS: #! Linux (Based on Debian stable, 6= 4-bit)
Emacs: 23.4.1
Org-mode: = 8.2.5h
Python: 2.7.3

<= /div>
TIA,
= --
<= /div>

--047d7b163827c145a204f71ed9a6--