Bulk transaction move

Sébastien de Menten sdementen at gmail.com
Sun Dec 28 16:14:45 EST 2014


Hello Thomas,

Great to hear you made it !  btw, in your script, the line "import piecash"
is not necessary as you import the function 'open_book' directly with the
"from piecash import open_book" (this is standard python and not related to
piecash itself).

I am surprised by what you noticed of needing to run multiple time the
script to handle all transactions. If you have inputs that can help
reproduce this bug (and that are not "confidential"/"private", you can send
them to me by email and I will inspect the run. But I would totally
understand your files are not "shareable" :-). I will test your script on
fake data to see if I can reproduce the issue.

To avoid using the gnucash mailing list to solve piecash issues, I would
suggest to not include the mailing list when replying (except if someone
says the contrary !). There is a place to post piecash issues on github
https://github.com/sdementen/piecash/issues

kr

Sebastien

On Sun, Dec 28, 2014 at 7:16 PM, Thomas Young <thomas at polywatt.com> wrote:

>  Hi Sebastien
>
> Many many thanks for the good advice and help. Not being up to snuff on
> Python or GC internals I went out and purchased a book on Python and did a
> little studying. I then executed your script with mostly good results
> saving myself a great deal of tedious effort. So far I have been unable to
> find any negative consequences to my database, so I have been quite happy
> for several days now. Not only did I save myself a lot of effort, I have
> been learning a few things as well. The mysterious aspect to the code
> execution is that i had to run it about 5 times on my database before it
> transferred all the target transactions. It would do many but not all on
> each pass.
>
> Here is my slightly modified version of your script.
>
> import piecash
> from piecash import open_book
> with open_book("test.gnucash",readonly=False) as s:
>     misc_acc = s.accounts.get(name="Miscellaneous")
>     new_acc = s.accounts.get(name="TEMP")
>     for spl in misc_acc.splits:
>         if spl.transaction.description == "Cash":
>             spl.account = new_acc
>     s.save()
>
> Sincerely
> Thomas Young
>
>
>
> On 12/24/2014 3:49 AM, Sébastien de Menten wrote:
>
> Hello Thomas,
>
>  With the recently released piecash (python interface to gnucash), if
> your gnucash file is in the sqlite format, you could do this with the
> following script:
>
>   from piecash import open_book
>
>   with open_book("sample1.gnucash",readonly=False) as s:
>      misc_acc = s.accounts.get(name="Miscellaneous")
>      new_acc = s.accounts.get(name="Other account")
>      for spl in misc_acc.splits:
>           if spl.transaction.description = "some descrption":
>               spl.account = new_acc
>     s.save()
>
>
>  kr
>
>  Sebastien
>
> On Tue, Dec 23, 2014 at 3:07 AM, Thomas Young <thomas at polywatt.com>
> wrote:
>>
>> Hello
>>
>> I have an account named Miscellaneous with about 1400 transactions and I
>> would like to move about 600 of them to a different account. Is there any
>> way of doing this in a bulk move instead of one by one? I have tried saving
>> my Gnucash file as Sqlite3 and editing account name records with openoffice
>> but the results have been essentially gibberish back in Gnucash. My
>> attempts with exporting and importing CSV have not been much better since
>> it seems CSV exporting does not include all data like memos for instance.
>>
>> Many thanks
>> Thomas
>> _______________________________________________
>> 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