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

UnicodeEncodeError - 'charmap' condec cant encode character #2

Open
eugjr opened this issue Oct 4, 2021 · 1 comment
Open

UnicodeEncodeError - 'charmap' condec cant encode character #2

eugjr opened this issue Oct 4, 2021 · 1 comment

Comments

@eugjr
Copy link

eugjr commented Oct 4, 2021

Hello, I'm trying to run a .py script to convert a .csv file to a .html table. I'm using this code as first try. I'm trying to run it on Win7.

import pyexcel as p

sheet = p.get_sheet(file_name='banks.csv', encoding="utf-8")
sheet.save_as('me.sortable.html', dest_encoding="utf-8", display_lenght=10)
from IPython.display import IFrame
IFrame("me.sortable.html", encoding="utf-8", width=600, height=500)

But I'm getting the following error:
UnicodeEncodeError: 'charmap' codec can't encode character '\u56fd' in position 239945: character maps to

As you can see in the code, I've even tryied to run the get and save sheets command with "enconding='utf-8' option, but didn't get any luck with it.

Even with a simple csv file with A,B,C,D,E and 1,2,3,4,5 data it gets the same error.

Above the complete output when running the script.

WARNING:excel2table:
Virtual scroll is enabled since number of rows exceeds -1. You can set custom row limit by setting flag -vs, --virtual
croll. Virtual scroll can be disabled by setting the value to -1 and set it to 0 to always enable.
Traceback (most recent call last):
  File "converte1.py", line 7, in <module>
    sheet.save_as('me.sortable.html', dest_encoding="utf-8", display_lenght=10)
  File "C:\Users\Sulamericana\AppData\Local\Programs\Python\Python38\lib\site-packages\pyexcel\internal\meta.py", line
60, in save_as
    return save_sheet(self, file_name=filename, **keywords)
  File "C:\Users\Sulamericana\AppData\Local\Programs\Python\Python38\lib\site-packages\pyexcel\internal\core.py", line
7, in save_sheet
    return _save_any(a_source, sheet)
  File "C:\Users\Sulamericana\AppData\Local\Programs\Python\Python38\lib\site-packages\pyexcel\internal\core.py", line
9, in _save_any
    a_source.write_data(instance)
  File "C:\Users\Sulamericana\AppData\Local\Programs\Python\Python38\lib\site-packages\pyexcel\plugins\sources\file_ou
ut.py", line 31, in write_data
    self._renderer.render_sheet_to_file(
  File "C:\Users\Sulamericana\AppData\Local\Programs\Python\Python38\lib\site-packages\pyexcel\renderer.py", line 87,
 render_sheet_to_file
    self.render_sheet(sheet, **keywords)
  File "C:\Users\Sulamericana\AppData\Local\Programs\Python\Python38\lib\site-packages\pyexcel_sortable\sortable.py",
ne 48, in render_sheet
    self._stream.write(js_freezed_html)
  File "C:\Users\Sulamericana\AppData\Local\Programs\Python\Python38\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u56fd' in position 239945: character maps to <undefined>
@chfw
Copy link
Member

chfw commented Oct 4, 2021

Can you configure your dos command prompt to use utf-8?

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