emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Sebastien Vauban <sva-news@mygooglest.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: [Babel] Lisp error: (wrong-type-argument listp hline)
Date: Mon, 23 Sep 2013 17:26:39 -0600	[thread overview]
Message-ID: <87ob7j15ci.fsf@gmail.com> (raw)
In-Reply-To: 86zjr3bp2y.fsf@somewhere.org

[-- Attachment #1: Type: text/plain, Size: 177 bytes --]

Hi Seb,

I think you're confused by headers which are re-added by the colnames
machinery.  See the following which returns scalar output avoiding any
colnames post-processing.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: hlines.org --]
[-- Type: text/x-org, Size: 353 bytes --]

#+Property: results scalar

#+name: table
| Key | Value |
|-----+-------|
| ABJ |     1 |
| DEK |     2 |

#+begin_src emacs-lisp :var data=table :hlines no
  data
#+end_src

#+RESULTS:
: (("Key" "Value") ("ABJ" 1) ("DEK" 2))

#+begin_src emacs-lisp :var data=table :hlines yes
  data
#+end_src

#+RESULTS:
: (("Key" "Value") hline ("ABJ" 1) ("DEK" 2))

[-- Attachment #3: Type: text/plain, Size: 1054 bytes --]


> * Set :hlines to "yes"
>
> `:hlines yes' should leave the horizontal line, but generates an error.
>
>   #+begin_src emacs-lisp :var data=table :results output :hlines yes
>   (mapc (lambda (item) (princ (format "UPDATE dim SET val=%s WHERE code='%s'\n"
>                                       (nth 1 item) (nth 0 item))))
>    data)
>   #+end_src

This is not a babel error, this is an error in your code block body,
which assumes that every element of `data' will be a list.  The symbol
`hline' is not a list.

>
> Finally, how am I then supposed to *ignore the header line*?  By adding
>
>   #+begin_src emacs-lisp
>   (setq table (cdr table))
>   #+end_src
>
> ?
>
> Do I have to do that explicitly in my code block, or is there an option for
> telling that to Babel?
>

Use the :colnames processing to strip the headings.

    #+begin_src emacs-lisp :var data=table :colnames yes
      data
    #+end_src

    #+RESULTS:
    : (("ABJ" 1) ("DEK" 2))

Best,

>
> Best regards,
>   Seb

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D

  reply	other threads:[~2013-09-23 23:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-23 14:16 [Babel] Lisp error: (wrong-type-argument listp hline) Sebastien Vauban
2013-09-23 23:26 ` Eric Schulte [this message]
2013-09-24  8:43   ` Sebastien Vauban
2013-09-28 12:21     ` [Babel] :colnames "no" no longer default for Emacs Lisp [Was] " Eric Schulte
2013-09-30  9:03       ` Sebastien Vauban
2013-10-01 22:04       ` Thomas S. Dye
2013-10-02 13:13         ` Eric Schulte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ob7j15ci.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=sva-news@mygooglest.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).