pypxlib icon indicating copy to clipboard operation
pypxlib copied to clipboard

Encoding issue

Open esn83 opened this issue 5 years ago • 4 comments

Hi, I'm not a programmer and I'm new to github, but I found this repo and I think it can help me as I'm working with some old paradox DB's. I'm getting an error regarding encoding. Can I somehow pass the encoing as a parameter? I happen to know the encoding I need is 'iso-8859-1'.

The error: UnicodeEncodeError: 'ascii' codec can't encode character '\xe6' in position 64: ordinal not in range(128)

esn83 avatar Oct 14 '20 08:10 esn83

Hi and welcome to programming and GitHub. The answer to your question is yes:

table = Table('data.db', encoding='iso-8859-1')

mherrmann avatar Oct 14 '20 09:10 mherrmann

Thank you!

However I'm still getting the same error:

line 44, in __init__
    if PX_open_file(self.pxdoc, file_path.encode(self.PX_ENCODING)) != 0:
UnicodeEncodeError: 'ascii' codec can't encode character '\xe6' in position 64: ordinal not in range(128)

The code looks like this:

import os.path
from pypxlib import Table
import pandas as pd

mappe = os.path.dirname(os.path.realpath(__file__))+'/TN25/'

table = Table(mappe+'HIGHLOW.DB', encoding='iso-8859-1')

I thought I might be a path error, but I don't think so.

esn83 avatar Oct 14 '20 11:10 esn83

Sorry, I don't have time to help with this further. I'd suggest you ask your question on StackOverflow.

mherrmann avatar Oct 14 '20 13:10 mherrmann

For those who are interested I resolved the issue by editing the __init__.py file changing the hardcoded encoding 'ascii' in PX_ENCODING to the correct encoding of the .DB file.

class Table(object):
	PX_ENCODING = 'ascii'

esn83 avatar Oct 22 '20 06:10 esn83