* ob-sql error because of not specifying column-seperator
@ 2010-12-03 13:01 Joost Helberg
2010-12-03 13:59 ` Eric Schulte
2010-12-03 14:49 ` Sébastien Vauban
0 siblings, 2 replies; 3+ messages in thread
From: Joost Helberg @ 2010-12-03 13:01 UTC (permalink / raw)
To: emacs-orgmode
Hi,
when using babel SQL, the column's in the resultset are converted to
org-tables using (org-table-import file sep).
The command used to retrieve the information from the databaseserver
gets the option to use the tab (\t) as columnseperator.
The call to org-table-import however doesn't specify this
seperator. This leaves it to org-table-import to find out what the
seperator is. org-table-import doesn't always succeed in this. Hence
the diff below which sets the seperator to <tab> (\t).
regards,
Joost Helberg
diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
index 19c271d..6bb9a96 100644
--- a/lisp/ob-sql.el
+++ b/lisp/ob-sql.el
@@ -80,7 +80,7 @@ This function is called by `org-babel-execute-src-block'."
(message command)
(shell-command command)
(with-temp-buffer
- (org-table-import out-file nil)
+ (org-table-import out-file '(16))
(org-babel-reassemble-table
(org-table-to-lisp)
(org-babel-pick-name (cdr (assoc :colname-names params))
--
Snow B.V. http://snow.nl
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: ob-sql error because of not specifying column-seperator
2010-12-03 13:01 ob-sql error because of not specifying column-seperator Joost Helberg
@ 2010-12-03 13:59 ` Eric Schulte
2010-12-03 14:49 ` Sébastien Vauban
1 sibling, 0 replies; 3+ messages in thread
From: Eric Schulte @ 2010-12-03 13:59 UTC (permalink / raw)
To: Joost Helberg; +Cc: emacs-orgmode
Applied, Thanks for the patch -- Eric
Joost Helberg <joost@snow.nl> writes:
> Hi,
>
> when using babel SQL, the column's in the resultset are converted to
> org-tables using (org-table-import file sep).
>
> The command used to retrieve the information from the databaseserver
> gets the option to use the tab (\t) as columnseperator.
>
> The call to org-table-import however doesn't specify this
> seperator. This leaves it to org-table-import to find out what the
> seperator is. org-table-import doesn't always succeed in this. Hence
> the diff below which sets the seperator to <tab> (\t).
>
> regards,
>
> Joost Helberg
>
> diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
> index 19c271d..6bb9a96 100644
> --- a/lisp/ob-sql.el
> +++ b/lisp/ob-sql.el
> @@ -80,7 +80,7 @@ This function is called by `org-babel-execute-src-block'."
> (message command)
> (shell-command command)
> (with-temp-buffer
> - (org-table-import out-file nil)
> + (org-table-import out-file '(16))
> (org-babel-reassemble-table
> (org-table-to-lisp)
> (org-babel-pick-name (cdr (assoc :colname-names params))
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: ob-sql error because of not specifying column-seperator
2010-12-03 13:01 ob-sql error because of not specifying column-seperator Joost Helberg
2010-12-03 13:59 ` Eric Schulte
@ 2010-12-03 14:49 ` Sébastien Vauban
1 sibling, 0 replies; 3+ messages in thread
From: Sébastien Vauban @ 2010-12-03 14:49 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Joost,
Joost Helberg wrote:
> when using babel SQL, the column's in the resultset are converted to
> org-tables using (org-table-import file sep).
>
> The command used to retrieve the information from the databaseserver
> gets the option to use the tab (\t) as columnseperator.
>
> The call to org-table-import however doesn't specify this
> seperator. This leaves it to org-table-import to find out what the
> seperator is. org-table-import doesn't always succeed in this. Hence
> the diff below which sets the seperator to <tab> (\t).
>
> regards,
>
> Joost Helberg
>
> diff --git a/lisp/ob-sql.el b/lisp/ob-sql.el
> index 19c271d..6bb9a96 100644
> --- a/lisp/ob-sql.el
> +++ b/lisp/ob-sql.el
> @@ -80,7 +80,7 @@ This function is called by `org-babel-execute-src-block'."
> (message command)
> (shell-command command)
> (with-temp-buffer
> - (org-table-import out-file nil)
> + (org-table-import out-file '(16))
> (org-babel-reassemble-table
> (org-table-to-lisp)
> (org-babel-pick-name (cdr (assoc :colname-names params))
Nice catch!
This one should improve the associated doc.
--8<---------------cut here---------------start------------->8---
lisp/org-table.el
--- INDEX:/lisp/org-table.el
+++ WORKDIR:/lisp/org-table.el
@@ -486,8 +486,8 @@ nil When nil, the command tries to be smart and figure out the
(goto-char beg)
(org-table-align)))
-(defun org-table-import (file arg)
- "Import FILE as a table.
+(defun org-table-import (file separator)
+ "Import FILE as a table, using specified field SEPARATOR.
The file is assumed to be tab-separated. Such files can be produced by most
spreadsheet and database applications. If no tabs (at least one per line)
are found, lines will be split on whitespace into fields."
@@ -496,7 +496,7 @@ are found, lines will be split on whitespace into fields."
(let ((beg (point))
(pm (point-max)))
(insert-file-contents file)
- (org-table-convert-region beg (+ (point) (- (point-max) pm)) arg)))
+ (org-table-convert-region beg (+ (point) (- (point-max) pm)) separator)))
(defvar org-table-last-alignment)
--8<---------------cut here---------------end--------------->8---
Best regards,
Seb
--
Sébastien Vauban
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-12-03 14:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-03 13:01 ob-sql error because of not specifying column-seperator Joost Helberg
2010-12-03 13:59 ` Eric Schulte
2010-12-03 14:49 ` Sébastien Vauban
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).