From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Re: Org-Babel and Ledger Date: Fri, 13 Aug 2010 11:41:31 -0600 Message-ID: <87iq3ewgtw.fsf@gmail.com> References: <87eiemsk0m.fsf@mundaneum.com> <87fwz2b634.fsf@pellet.net> <87tyng66ja.fsf@gmail.com> <87vd7gyrz6.fsf@mundaneum.com> <871va3v3qk.fsf@gmail.com> <87zkwqzx0p.fsf@mundaneum.com> <87fwyizr0f.fsf@mundaneum.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from [140.186.70.92] (port=57860 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OjyGB-0005Hl-Mo for emacs-orgmode@gnu.org; Fri, 13 Aug 2010 13:41:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OjyG9-0006XA-DM for emacs-orgmode@gnu.org; Fri, 13 Aug 2010 13:41:39 -0400 Received: from mail-px0-f169.google.com ([209.85.212.169]:51771) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OjyG8-0006Wq-Kb for emacs-orgmode@gnu.org; Fri, 13 Aug 2010 13:41:37 -0400 Received: by pxi5 with SMTP id 5so1574334pxi.0 for ; Fri, 13 Aug 2010 10:41:35 -0700 (PDT) In-Reply-To: <87fwyizr0f.fsf@mundaneum.com> (=?utf-8?Q?=22S=C3=A9bastien?= Vauban"'s message of "Fri, 13 Aug 2010 13:33:20 +0200") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: =?utf-8?Q?S=C3=A9bastien?= Vauban Cc: emacs-orgmode@gnu.org Hi Seb, S=C3=A9bastien Vauban writes: > Hi Eric, > > S=C3=A9bastien Vauban wrote: >> "Eric Schulte" wrote: >>> S=C3=A9bastien Vauban writes: >>>> >>>>>>> As you can see, the tables are completely wrongly made, because the= y're >>>>>>> based on spaces ("=C3=A0 la Awk") and not on fixed position of fiel= ds ("=C3=A0 la >>>>>>> Cut"). >>>>>>> >>>>>>> What can I do about this? >>>>>>> >>>>>>> - Post-process every ledger command with some awk or cut command th= at >>>>>>> will do whatever is needed This might actually be a good solution for the shell block you mention below. >>>>> >>>>> (org-table-convert-region (point-min) (point-max)) > > As you adviced, I can play with the optional parameter in ob-ledger's cod= e. > > But what about the results of sh code? > > Imagine now that I'm forced to use =3Dsh=3D instead of =3Dledger=3D, in t= he following > pratical case: > > #+srcname: reg > #+begin_src sh > m4 scorpios-ledger.dat | ledger -f - reg unknown > #+end_src > > I'm using =3Dm4=3D (and thus make some pre-processing) because I need (or= want) to > be able to switch between =3Dledger=3D and =3Dhledger=3D and comment in o= r out the > directives that are accepted by one but not by the other. > > Then, such a result is still problematic: > > 09-Aug-21 CHEQUE : 9953055 Expenses:Unknown = 166.70 EUR 166.70 EUR > 09-Sep-17 CHEQUE : 7691785 Expenses:Unknown = 100.00 EUR 266.70 EUR > 09-Oct-16 REMISE CHEQUE N 8686318 001 105 Expenses:Unknown = -525.00 EUR -258.30 EUR > > I've looked in =3Dorg-babel-execute:sh=3D and =3Dorg-babel-reassemble-tab= le=3D, among > others, to look for similar constructs (calls to =3Dorg-table-convert-reg= ion=3D) > but did not find any. > > Is there still a solution to get such results? > As an interim solution you could add a :results scalar header argument to your sh code block, then pass the output of that code block to a parsing code block (namely the one from my previous email). That's certainly not idea, but it should work for the moment. Alternately if ledger supports a more clearly delimited output format (e.g. csv) then that would probably work as well. > > #+results: > | 09-Aug-21 CHEQUE : 9953055 | Expenses:Unknown | 166.70 E= UR | 166.70 EUR | > | 09-Sep-17 CHEQUE : 7691785 | Expenses:Unknown | 100.00 E= UR | 266.70 EUR | > | 09-Oct-16 REMISE CHEQUE N 8686318 001 105 | Expenses:Unknown | -525.00 = EUR | -258.30 EUR | > > Couldn't we specify somehow the field separator as an extra header > argument? I've looked for such an already existing in > http://orgmode.org/manual/Specific-header-arguments.html#Specific-header-= arguments, > but that does not seem to be available yet. This would probably be a good addition to ob-sh (and any other language which doesn't have a defined list syntax). I'll add this idea to the babel dev stack, but I'm swamped for the next week or so. Best -- Eric > Though, I do not know if this is the right solution. I'm sure you'll > tell me...=C2=A0;-) > > Best regards, > Seb