From e4902db7bf0f06d427c5115af0af3f8ad4cbcb83 Mon Sep 17 00:00:00 2001 From: Victor Ngeno Date: Wed, 29 May 2019 15:02:00 +0300 Subject: [PATCH 1/2] utf-8 encode string before writing to html file. See https://github.com/socialcopsdev/camelot/issues/322 --- camelot/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camelot/core.py b/camelot/core.py index 63425cc6..208f9fcf 100644 --- a/camelot/core.py +++ b/camelot/core.py @@ -598,7 +598,7 @@ def to_html(self, path, **kwargs): """ html_string = self.df.to_html(**kwargs) with open(path, 'w') as f: - f.write(html_string) + f.write(html_string.encode('utf-8')) def to_sqlite(self, path, **kwargs): """Writes Table to sqlite database. From 41665a19ed89d27a4b107096912cede6d0012565 Mon Sep 17 00:00:00 2001 From: Victor Ngeno Date: Thu, 30 May 2019 09:37:46 +0300 Subject: [PATCH 2/2] Open html file to write to with utf-8 encoding --- camelot/core.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/camelot/core.py b/camelot/core.py index 208f9fcf..fef5a35b 100644 --- a/camelot/core.py +++ b/camelot/core.py @@ -597,8 +597,8 @@ def to_html(self, path, **kwargs): """ html_string = self.df.to_html(**kwargs) - with open(path, 'w') as f: - f.write(html_string.encode('utf-8')) + with open(path, 'w', encoding='utf-8') as f: + f.write(html_string) def to_sqlite(self, path, **kwargs): """Writes Table to sqlite database.