I've been playing with Beancount API for some custom interactive importers, 
and so far it is doing everything I want, except (perhaps) for one thing.

I would like to make a `merge` that takes the new entries generated by the 
import and inserts them in the main file (let's assume only one file for 
now), in the right location ordering them by date.

So I did the obvious round-trip (for the time being to a new file):

    existing, err, opts = load_file(main)
    if err:
        raise Exception("The main file contains errors. Aborting")
    new, _, _ = load_file(filename)
    existing.extend(new)

    res = sorted(existing, key=lambda c: c.date)

    with open(f"{main}_new", "w") as f:
        print_entries(res, file=f)

But this way comments, tags, options (perhaps more) are not preserved.

Is there a simple way to do this?

Thanks

M.

-- 
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/fe38849b-79e5-4055-b77e-d5ba6f3cd920%40googlegroups.com.

Reply via email to