emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: Eric Abrahamsen <eric@ericabrahamsen.net>
Cc: emacs-orgmode@gnu.org
Subject: Re: Re: Org-Babel and Ledger
Date: Fri, 30 Jul 2010 14:47:37 -0600	[thread overview]
Message-ID: <87tyng66ja.fsf@gmail.com> (raw)
In-Reply-To: <87fwz2b634.fsf@pellet.net> (Eric Abrahamsen's message of "Thu, 29 Jul 2010 09:33:51 -0700")

Many languages import tabular contents into elisp tables which are then
inserted into Org-mode buffers as Org-formatted tables.  This should be
possible by replacing the call to `buffer-string' at the end of the
`org-babel-execute:ledger' function with something analogous to the
following (copied from ob-sqlite.el).

--8<---------------cut here---------------start------------->8---
(if (or (member "scalar" result-params)
	      (member "html" result-params)
	      (member "code" result-params)
	      (equal (point-min) (point-max)))
	  (buffer-string)
	(org-table-convert-region (point-min) (point-max))
	(org-babel-sqlite-table-or-scalar
	 (org-babel-sqlite-offset-colnames
	  (org-table-to-lisp) headers-p)))
--8<---------------cut here---------------end--------------->8---

I would recommend this approach over shell-script post-processing.

Best -- Eric

Eric Abrahamsen <eric@ericabrahamsen.net> writes:

> On Thu, Jul 29 2010, Sébastien Vauban wrote:
>
>
> [...]
>
>>
>> As you can see, the tables are completely wrongly made, because they're based
>> on spaces ("à la Awk") and not on fixed position of fields ("à la Cut").
>>
>> What can I do about this?
>>
>> - Post-process every ledger command with some awk or cut command that will do
>>   whatever is needed
>>
>> - Exploit the CSV export format (never tried, don't have Ledger 3 installed
>>   yet -- and I'm also using hledger...)
>>
>> - Other ideas?
>
>  Couldn't you use ledger's format strings for fine-tuned control of
>  the command output? I don't know how you're snarfing the output, but it
>  seems like you could using formatting to produce something that already
>  looks very much like an org table, or perhaps CSV.
>
> Eric
>
>>
>> Do you have suggestions about the best way to go?
>>
>> Best regards,
>>   Seb
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

  reply	other threads:[~2010-07-30 20:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-29  9:40 Org-Babel and Ledger Sébastien Vauban
2010-07-29 16:33 ` Eric Abrahamsen
2010-07-30 20:47   ` Eric Schulte [this message]
2010-08-12 11:45     ` Sébastien Vauban
2010-08-12 22:57       ` Eric Schulte
2010-08-13  9:23         ` Sébastien Vauban
2010-08-13 11:33           ` Sébastien Vauban
2010-08-13 17:41             ` Eric Schulte
2010-08-13 19:04               ` Sébastien Vauban

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=87tyng66ja.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=eric@ericabrahamsen.net \
    /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).