merging gnucash

hendrik at topoi.pooq.com hendrik at topoi.pooq.com
Sun Oct 12 20:43:36 EDT 2008


On Sun, Oct 12, 2008 at 05:56:35PM +0200, matteo brutti wrote:
> hi all,
> i did a big mistake!
> i opened and modified a previous file of my gnucash account book,
> replacing the newer one. Now i found this mistake i would to merge the
> old modified and the new unmodified. I know i have logs to handmade,
> but there are so many modification... is there a way to do it
> automatically?
> And there is some options to change the directory where gnucash puts
> it's log and old gnucash files?
> 
> best regards.

This *may* work, but it might not, and it might create a horrible 
mishmash which doesn't work at all, or a result that has a few 
transactions wrong.

You have an original gnucash file I'll call A, and two modified ones 
I'll call B and C.

Make copies of these files, and work on the copies instead, just in 
case.  Make the copies in a *different* directory and work there, so you 
won't accidentally do horrible things to your originals.
 
(1) uncompress them all (I think the command is gunzip) giving files 
Au, Bu, and Cu.

(2) Use diff3 to produce a file Du.  diff3 takes three files, assumes 
one is an original and the others are modifications, computes the 
differences between the original and the modifications, merges the
differences and then creates a new file from the original that contains 
both sets of differences.

If all goes well, Du will be the merged file you are looking for.

***

But all may not go well, for several reasons:
(1) diff3 may discover conflicting changes, in which case it doesn't 
know which to apply.  It has some way to report this.

(2) Somewhere within the gnucash file is a number which indicates the 
number of transactions in the file.  diff3 won't get this right; you'd 
have to adjust it by hand.

(3) diff3 works on a line-by-line basis, and what you need is something 
that works on a transaction-by-transaction basis.  In the unzipped 
gnucash files, one transaction usually takes several lines.  diff3 might 
just decide a change involves the end of one transaction and the start 
of another, because it can gets confused when many lines are the same.
In this case your final file may contains phantom transactions composed 
of pieces of old transactions, which may also have been modified.
(If you can hack XML, you can get around this to an extent by rewriting 
the gnucash files so that every transaction is on a line by itself.)

***

Because of these problems, you will have to find some way of checking 
the results of this merge.  Reentering the transactions might be easier.

-- hendrik



> 
> 
> Matteo Brutti
> _______________________________________________
> gnucash-user mailing list
> gnucash-user at gnucash.org
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> -----
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.


More information about the gnucash-user mailing list