Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding of output file #1

Open
briot opened this issue Mar 4, 2024 · 0 comments
Open

Encoding of output file #1

briot opened this issue Mar 4, 2024 · 0 comments

Comments

@briot
Copy link

briot commented Mar 4, 2024

Hello,
Thanks for the converter. I found it by chance yesterday while I was considering writing my own :-)
A minor suggestion for a fix: some of my accounts use accented letters. There is also apparently somewhere an infinity sign, though I could not find it in the XML file itself.
Nonetheless, when running your tool in Windows Powershell, I am getting

> python3 .\kmymoney2ledgers.py .\test_kmy_xml.xml
Processing transaction 2/8703
Processing transaction 1002/8703
Processing transaction 2002/8703
Processing transaction 3002/8703
Processing transaction 4002/8703
Processing transaction 5002/8703
Processing transaction 6002/8703
Processing transaction 7002/8703
Processing transaction 8002/8703
Processing transaction 8703/8703
Traceback (most recent call last):
  File "C:\Users\briot\Desktop\kmymoney2ledgers.py", line 438, in <module>
    main(sys.argv)
  File "C:\Users\briot\Desktop\kmymoney2ledgers.py", line 430, in main
    out_file_id.writelines(
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2288.0_x64__qbz5n2kfra8p0\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The simple fix I applied was to change line 439 to

    out_file_id = open(outputfile, "w", encoding="utf-8")

It likely isn't the optimal, maybe we should just apply the encoding of the input XML file itself, though I think kmymoney might always be using UTF-8 in any case.

thanks
Emmanuel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant