emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Orgmode] Re: Org-Babel and Ledger


From: Sébastien Vauban
Subject: [Orgmode] Re: Org-Babel and Ledger
Date: Fri, 13 Aug 2010 21:04:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Hi Eric,

"Eric Schulte" wrote:
> Sébastien Vauban <address@hidden> writes:
>> Sébastien Vauban wrote:
>>> "Eric Schulte" wrote:
>>>> Sébastien Vauban writes:
>>>>>
>>>>>>>> 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
>
> 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 code.
>>
>> But what about the results of sh code?
>>
>> Imagine now that I'm forced to use =sh= instead of =ledger=, in the
>> following pratical case:
>>
>> #+srcname: reg
>> #+begin_src sh
>> m4 scorpios-ledger.dat | ledger -f - reg unknown
>> #+end_src
>>
>> I'm using =m4= (and thus make some pre-processing) because I need (or want)
>> to be able to switch between =ledger= and =hledger= and comment in or 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 =org-babel-execute:sh= and =org-babel-reassemble-table=,
>> among others, to look for similar constructs (calls to
>> =org-table-convert-region=) 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 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 |
>>
>> 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 have a deep look in the proposed direction.

> I'll add this idea to the babel dev stack, but I'm swamped for the next week
> or so.

If it's for holidays, enjoy it!  (and, accessorily, come back full of
energy ;-))

Best regards,
  Seb

-- 
Sébastien Vauban




reply via email to

[Prev in Thread] Current Thread [Next in Thread]