From mboxrd@z Thu Jan 1 00:00:00 1970 From: Darlan Cavalcante Moreira Subject: Re: [babel] sbe not working properly Date: Thu, 11 Apr 2013 15:00:20 -0300 Message-ID: <5166fa3a.054bec0a.3a8e.5d36@mx.google.com> References: <2013-04-11T16-21-52@devnull.Karl-Voit.at> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from eggs.gnu.org ([208.118.235.92]:43489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQLnV-0004Gw-G4 for emacs-orgmode@gnu.org; Thu, 11 Apr 2013 14:00:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UQLnQ-0000yw-GP for emacs-orgmode@gnu.org; Thu, 11 Apr 2013 14:00:33 -0400 Received: from mail-yh0-x22c.google.com ([2607:f8b0:4002:c01::22c]:55572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UQLnQ-0000yh-Co for emacs-orgmode@gnu.org; Thu, 11 Apr 2013 14:00:28 -0400 Received: by mail-yh0-f44.google.com with SMTP id m1so283928yhg.17 for ; Thu, 11 Apr 2013 11:00:27 -0700 (PDT) In-Reply-To: <2013-04-11T16-21-52@devnull.Karl-Voit.at> 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: news1142@Karl-Voit.at Cc: emacs-orgmode@gnu.org I have my own difficulties using sbe and decided to try your example. I even created the shell babel block below which does the same think as the python code #+NAME: epoch2dayshell(epoch=1) #+begin_src sh echo `date --d @$epoch -u +"[%F %a %T]"` #+end_src but I got the same result. Actually, I realize a small detail. In your example, when you evaluated the table formula you got as result the 1970 date. However, this does not mean that your python code was executed. You got that answer because you have evaluated the python code previously with the default argument (equal to 1) and thus you had #+RESULTS: epoch2day : [1970-01-01 Thu 00:00:01] in your file. If you erase the #+RESULTS and reevaluate the table you will get an ERROR. That indicates that sbe is not calling the babel block as I (and probably you too) was expecting. However, looking at sbe's documentation I can't see anything wrong with the formula you wrote. I'm still confused on how to correctly use sbe. -- Darlan At Thu, 11 Apr 2013 16:26:12 +0200, Karl Voit wrote: > > Hi! > > I want to define a babel function named epoch2day which I am able to use in a > table to convert UNIX epoch times to Org-mode time stamps: > > #+NAME: epoch2day(epoch=1) > #+BEGIN_SRC python :results output > time = epoch > import datetime > strtime = str(time) > datetimestamp = datetime.datetime.utcfromtimestamp(int(strtime[:10])) > print datetimestamp.strftime('[%Y-%m-%d %a %H:%M:%S]') > #+END_SRC > > #+RESULTS: epoch2day > : [1970-01-01 Thu 00:00:01] > > ... this works so far. However, in a table I can't "overwrite" the default > value with a column value: > > | epoch | day | > |---------------+---------------------------| > | 1262675465119 | [1970-01-01 Thu 00:00:01] | > #+TBLFM: $2='(sbe epoch2day (epoch $1)) > > ... but $2 should be: [2010-01-05 Tue 07:11:05] > > > On [1] I found another example: > > #+name: add1(x=1) :results silent > #+begin_src python > return x + 1 > #+end_src > > #+RESULTS: add1 > : 2 > > | foo | bar | 3 | 2 | > #+TBLFM: @1$4='(sbe add1 (x $3)) > > #+CALL: add1(x=2) > > #+RESULTS: add1(x=2) > : 2 > > So this simple example does not work either at my side[2]. > > > What is my error? Or did I found a bug? > > Thanks! > > > 1. http://stackoverflow.com/questions/9595310/org-babel-sbe-syntax > 2. Org-mode 1af215bb4668bf3e778175e68fcaf from git > -- > mail|git|SVN|photos|postings|SMS|phonecalls|RSS|CSV|XML to Org-mode: > > get Memacs from https://github.com/novoid/Memacs < > > https://github.com/novoid/extract_pdf_annotations_to_orgmode + more on github > >