GnuCash import difficulty and interim solution

Jonathan Kimmitt jonathan at kimmitt.uk
Sun Jan 7 08:12:59 GMT 2024


Here is an example file created without personally identifiable data. It still shows the same problem. I also attach the output of my converter for reference.
Not sure if attachments will be scrubbed.

On 7 Jan 2024, at 07:24, Jonathan Kimmitt <jonathan at kimmitt.uk> wrote:

This is the head of my file:

<?xml version="1.0" encoding="utf-8" ?>
<gnc-v2
     xmlns:gnc="http://www.gnucash.org/XML/gnc"
     xmlns:act="http://www.gnucash.org/XML/act"
     xmlns:book="http://www.gnucash.org/XML/book"
     xmlns:cd="http://www.gnucash.org/XML/cd"
     xmlns:cmdty="http://www.gnucash.org/XML/cmdty"
     xmlns:price="http://www.gnucash.org/XML/price"
     xmlns:slot="http://www.gnucash.org/XML/slot"
     xmlns:split="http://www.gnucash.org/XML/split"
     xmlns:sx="http://www.gnucash.org/XML/sx"
     xmlns:trn="http://www.gnucash.org/XML/trn"
     xmlns:ts="http://www.gnucash.org/XML/ts"
     xmlns:fs="http://www.gnucash.org/XML/fs"
     xmlns:bgt="http://www.gnucash.org/XML/bgt"
     xmlns:recurrence="http://www.gnucash.org/XML/recurrence"
     xmlns:lot="http://www.gnucash.org/XML/lot"
     xmlns:addr="http://www.gnucash.org/XML/addr"
     xmlns:billterm="http://www.gnucash.org/XML/billterm"
     xmlns:bt-days="http://www.gnucash.org/XML/bt-days"
     xmlns:bt-prox="http://www.gnucash.org/XML/bt-prox"
     xmlns:cust="http://www.gnucash.org/XML/cust"
     xmlns:employee="http://www.gnucash.org/XML/employee"
     xmlns:entry="http://www.gnucash.org/XML/entry"
     xmlns:invoice="http://www.gnucash.org/XML/invoice"
     xmlns:job="http://www.gnucash.org/XML/job"
     xmlns:order="http://www.gnucash.org/XML/order"
     xmlns:owner="http://www.gnucash.org/XML/owner"
     xmlns:taxtable="http://www.gnucash.org/XML/taxtable"
     xmlns:tte="http://www.gnucash.org/XML/tte"
     xmlns:vendor="http://www.gnucash.org/XML/vendor">
<gnc:count-data cd:type="book">1</gnc:count-data>
<gnc:book version="2.0.0">


On 6 Jan 2024, at 23:36, Jack via KMyMoney-devel <kmymoney-devel at kde.org> wrote:

Can you open the file in a text editor and confirm that it meets the criteria Thomas listed, specifically that the string "<gnc-v" followed by one or more digits" occurs within the first 70 bytes of the file?

On 2024.01.06 17:29, Jonathan Kimmitt via KMyMoney-devel wrote:
I see no dialogue box. My gnucash XML file is uncompressed. My file is chosen from a pop up window so it must exist. I can try the Linux version another time to see if there are terminal messages. However my GnuCash is v5.4 and the documentation says that the importer was designed for v2.x
Sent from my iPhone
> On 6 Jan 2024, at 21:40, Thomas Baumgart via KMyMoney-devel <kmymoney-devel at kde.org> wrote:
>
> On Samstag, 6. Januar 2024 18:24:47 CET Jack via KMyMoney-devel wrote:
>
>>> On 1/6/24 12:17, Jonathan Kimmitt wrote:
>>> Yes, it is present and has version GNC Importer Version 5.1.3-33a66be8a. Under OSX it’s in KMyMoney preferences instead of Setting
>>>
>>> It’s probably something stupid like an account or payee name with an & in is represented unadorned in the XML whereas KMyMoney requires &
>> That is certainly possible, but I'll have to look into the code to see
>> what exactly triggers that particular error message.  If you are right,
>> then we would want to find a utility that checks XML files for proper
>> encoding/markup (I can't think of the exact term right now.)
>
> Encoding and structure are the two important things. xmllint would be the tool to use.
>
> I scanned the GNC plugin's open() call real quick. Here is what it checks:
>
> - file is not a database (e.g. SQL, SQLite, ...)
> - file is on local drive (url starts with file://)
> - file is readable
> - if file is gzip compressed (first two bytes are "\037\213") it re-opens it
>  for decompression
> - first bytes in file are not "SQ"
> - the first 70 bytes of the file must contain the regex "<gnc-v(\\d+)"
>
> In case all that is true, a dialog is shown. This contains a switch
> to turn on debug messages which are printed to the console (in case
> KMyMoney was started via terminal) while the file is parsed. Now I have
> two questions: Does the dialog is shown? Do these debug messages provide
> any hint or details why the import fails?
>
> Thomas
>
>
>
>
>>>> On 6 Jan 2024, at 17:10, Jack via KMyMoney-devel <kmymoney-devel at kde.org> wrote:
>>>>
>>>> On 1/6/24 11:40, Jonathan Kimmitt via KMyMoney-devel wrote:
>>>>> Hi Jack,
>>>>>   I am using Apple M1 macOS 14.2.1 (23C71), with GnuCash Version: 5.4 Build ID: 5.4+(2023-09-23) and KMyMoney Version 5.1.3-33a66be8a
>>>>>
>>>>> The converter was written with OCaml 5.0.0 but I would not expect any lack of portability for the XML handling.
>>>>>
>>>>> The error when trying to open the GnuCash XML  in the GUI was:
>>>>> Could not read your data source. Please check the KMyMoney settings that the necessary plugin is enabled.
>>>>>
>>>>> Based on what Mark was saying, it sounds like the failure is something quite trivial, however I lack the knowledge to debug it.
>>>>>
>>>>> Regards,
>>>>> Jonathan
>>>> I'll have to do some digging, but the first step would be to assure the file can be read.  If it is on a local drive and you can look at it in a text editor, then that's OK.  The next step would be to assure that the guncash importer is present and enabled.  Go to Setting/Configure KMyMoney... select Plugins on the left side, and see if GNC Importer is present on the right.  If it's there, then we do have an interesting problem.  If it is NOT present, then we need to figure out why not.  I just confirmed it IS present in the Appimage versions, but I don't know about the macOS version.
>>
>>
>
> --
>
> Regards
>
> Thomas Baumgart
>
> -------------------------------------------------------------
> Ilde servers are the devil's work -- robbyoconnor on #irc
> -------------------------------------------------------------



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kmymoney-devel/attachments/20240107/c3e8be1d/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.xml
Type: application/xml
Size: 23290 bytes
Desc: example.xml
URL: <http://mail.kde.org/pipermail/kmymoney-devel/attachments/20240107/c3e8be1d/attachment-0001.xml>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: example.gnucash
Type: application/octet-stream
Size: 55739 bytes
Desc: example.gnucash
URL: <http://mail.kde.org/pipermail/kmymoney-devel/attachments/20240107/c3e8be1d/attachment-0001.obj>


More information about the KMyMoney-devel mailing list