Nice. Thank you for sharing. Are you able to customize what data structures it fills? In v3 there's a schema for protos, that can be compiled to many languages. https://github.com/beancount/beancount/tree/master/beancount/ccore/data.proto
Also, with protos you can use gRPC to build a server that accepts the same schema. Just some ideas, On Sat, Dec 5, 2020 at 11:59 PM polarmutex <[email protected]> wrote: > I have been working on a tree-sitter parser for beancount, the node tree > produced has the starting / ending line/column of the parsed file. > > https://tree-sitter.github.io/ > https://github.com/bryall/tree-sitter-beancount > > with that info you should be able to sort the ledger file > > I still think my parser has some edge cases that may not work, bu t I see > no errors in my files so far > > I am writing a beancount language server currently, I may be able to add a > code action to do this sorting in the LSP in the future > > On Saturday, December 5, 2020 at 6:14:27 AM UTC-5 Casey Link wrote: > >> Many thanks for this script! >> >> Some years ago when I started with beancount I decided to use one >> beancount file, but separate the accounts by Org headings. This worked for >> awhile, but now with thousands and thousands of lines it can be confusing >> to work with. It's much nicer to have everything sorted chronologically. >> Your script worked perfectly help me reorganize my beancount file. >> >> Thanks again! >> >> Best, >> Casey >> >> On Friday, December 20, 2019 at 4:29:33 PM UTC+1 [email protected] >> wrote: >> >>> I wrote a (albeit-hacky) python script to do this for my ledger and made >>> it public here: >>> https://github.com/robmargo/beancount_tools/blob/master/sort_transactions.py >>> >>> It ignores all lines before a line that has the text "TRANSACTIONS" >>> (everything above that line is account openings/metadata that I dont want >>> to sort). If you need help tweaking this for your needs, let me know. >>> >>> >>> On Friday, December 20, 2019 at 9:30:37 AM UTC-5, nug get wrote: >>>> >>>> thanks, a python script would probably do it in the end. >>>> is there a beancount function that would return all objects in my >>>> ledger file as list or something? Writing that myself would be beyond my >>>> current capabilities, or of irresponsible effort timewise :) >>>> >>>> >>>> >>>> On Friday, 20 December 2019 13:57:54 UTC+1, Martin Blais wrote: >>>>> >>>>> You will want to write a little python script. >>>>> I would operate on source code, not on the data structures, so you >>>>> keep the original formatting and metadata and comments >>>>> >>>>> On Fri, Dec 20, 2019, 06:59 nug get <[email protected]> wrote: >>>>> >>>>>> Is there a feature that would allow me to sort the transactions in my >>>>>> files, for example by date, or specific accounts? >>>>>> Thanks! >>>>>> >>>>>> Background: >>>>>> I migrated my 3 years of Gnucash records to beancount. It's all one >>>>>> long list of transactions sorted by date. I'd like to separate my cash >>>>>> and >>>>>> bank account transactions into two different files. >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Beancount" group. >>>>>> To unsubscribe from this group and stop receiving emails from it, >>>>>> send an email to [email protected]. >>>>>> To view this discussion on the web visit >>>>>> https://groups.google.com/d/msgid/beancount/4b6c37cd-dab7-4683-80fc-e6affac7e1ca%40googlegroups.com >>>>>> <https://groups.google.com/d/msgid/beancount/4b6c37cd-dab7-4683-80fc-e6affac7e1ca%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> >>>>> -- > You received this message because you are subscribed to the Google Groups > "Beancount" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/beancount/4396ceeb-4d8c-49d1-9ccb-1acc4927c896n%40googlegroups.com > <https://groups.google.com/d/msgid/beancount/4396ceeb-4d8c-49d1-9ccb-1acc4927c896n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Beancount" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/CAK21%2BhOwkFhQHJn53MuJhyQcpYBYOGi-p%3DcZSnQNEF%2Bfjj1yhQ%40mail.gmail.com.
