quentinsf / icsv2ledger

Interactive importing of CSV files to Ledger
196 stars 70 forks source link

Invalid ledger file encoding #94

Open artkpv opened 8 years ago

artkpv commented 8 years ago

Thanks for the great tool! Here is an error.

Given file in UTF-8, under Windows 10, Powershell 5, Python 3, I call:

py -3 .\icsv2ledger\icsv2ledger.py -c .icsv2ledgerrc -a ROCKET --quiet --encoding utf-8 .\rub.pdf.csv

And it breaks with:

Traceback (most recent call last):
  File ".\icsv2ledger\icsv2ledger.py", line 867, in <module>
    main()
  File ".\icsv2ledger\icsv2ledger.py", line 744, in main
    csv_comments = csv_from_ledger(options.ledger_file)
  File ".\icsv2ledger\icsv2ledger.py", line 579, in csv_from_ledger
    for line in f:
  File "C:\Users\art\AppData\Local\Programs\Python\Python35-32\lib\encodings\cp1251.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 1020: character maps to <undefined>

How to fix it?

UPDATE.

578:    with open(ledger_file) as f:
579:        for line in f: