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

Multi-encoding support in playhouse DataSet #2425

Closed
JarneVerhaeghe opened this issue Jun 4, 2021 · 0 comments
Closed

Multi-encoding support in playhouse DataSet #2425

JarneVerhaeghe opened this issue Jun 4, 2021 · 0 comments

Comments

@JarneVerhaeghe
Copy link

It appears the DataSet module from playhouse does not support other encodings such as 'latin-1'.

I locally solved it by adjusting the open_file, thaw, and freeze function to have an extra argument:
Line 21-22

def open_file(f, mode,encoding_='utf8'):
        return open(f, mode, encoding=encoding_)

Line 152-156

def freeze(self, query, format='csv', filename=None, file_obj=None, encoding='utf8',
               **kwargs):
        self._check_arguments(filename, file_obj, format, self._export_formats)
        if filename:
            file_obj = open_file(filename, 'w',encoding)

Line 164-168

 def thaw(self, table, format='csv', filename=None, file_obj=None,
           strict=False, encoding='utf8', **kwargs):
      self._check_arguments(filename, file_obj, format, self._export_formats)
      if filename:
          file_obj = open_file(filename, 'r',encoding)

This issue is more of a suggestion for multi-encoding support. I did not want to open a pull request for this.

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