You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When saving a table with the save message, an exception occurs in Windows.
Reproducible example
Run pandas/jupyter on a windows maching
create a simple table
try saving e.g. df.pipe(GT).save('test.pdf')
The bottom of the stack trace shows this
File D:\Python\Python312\Lib\site-packages\great_tables\_export.py:310, in save(self, file, selector, scale, expand, web_driver, window_size, debug_port, _debug_dump)
303 with (
304 tempfile.TemporaryDirectory() as tmp_dir,
305 wdriver(options=wd_options) as headless_browser,
306 ):
307
308 # Write the HTML content to the temp file
309 with open(f"{tmp_dir}/table.html", "w") as temp_file:
--> 310 temp_file.write(html_content)
312 # Open the HTML file in the headless browser
313 headless_browser.set_window_size(window_size[0], window_size[1])
File D:\Python\Python312\Lib\encodings\cp1252.py:19, in IncrementalEncoder.encode(self, input, final)
18 def encode(self, input, final=False):
---> 19 return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2212' in position 7916: character maps to <undefined>
Note that the error occurs due to CP1252 encoding which is the default. I fixed it by adding encoding='utf-8' ib line 309 of the _export.py file:
# Write the HTML content to the temp file
with open(f"{tmp_dir}/table.html", "w", encoding='utf-8') as temp_file:
temp_file.write(html_content)
(Sorry I'm not comfortable with pull requests I don't want to ruin anything)
Expected result
A file test.pdf should be created
Development environment
Operating System: Windows 10, Python 3.12.4
great_tables Version: 0.11.0
The text was updated successfully, but these errors were encountered:
Encountering the same issue when trying to utilize a Unicode character in the heading section (in lieu of an image). Unable to figure out a workaround yet without just removing the character.
Description
When saving a table with the
save
message, an exception occurs in Windows.Reproducible example
df.pipe(GT).save('test.pdf')
The bottom of the stack trace shows this
Note that the error occurs due to CP1252 encoding which is the default. I fixed it by adding
encoding='utf-8'
ib line 309 of the _export.py file:(Sorry I'm not comfortable with pull requests I don't want to ruin anything)
Expected result
A file
test.pdf
should be createdDevelopment environment
The text was updated successfully, but these errors were encountered: