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 issue #24

Open
esn83 opened this issue Oct 14, 2020 · 4 comments
Open

Encoding issue #24

esn83 opened this issue Oct 14, 2020 · 4 comments

Comments

@esn83
Copy link

esn83 commented Oct 14, 2020

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)

@mherrmann
Copy link
Owner

mherrmann commented Oct 14, 2020

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

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

@esn83
Copy link
Author

esn83 commented Oct 14, 2020

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.

@mherrmann
Copy link
Owner

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

@esn83
Copy link
Author

esn83 commented Oct 22, 2020

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'

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

2 participants