0
import pandas as pd

msf=pd.read_excel('‪C:\Users\pauldufosse\Documents\TESTDANIEL.xlsx', has_index_names=True)

I'm having difficulties importing this xlsx document.

I will give you the full traceback as you might help me to find WHERE the wrong byte is. I'm french so there is the character 'à' but I think this one is taken in charge by ascii/utf-8 am i right?

runfile('C:/Users/pauldufosse/Documents/MSF.py', wdir='C:/Users/pauldufosse/Documents') Traceback (most recent call last):

File "C:\Users\pauldufosse\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3052, in run_code self.showtraceback()

File "C:\Users\pauldufosse\Anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 1851, in showtraceback value, tb, tb_offset=tb_offset)

File "C:\Users\pauldufosse\Anaconda\lib\site-packages\IPython\core\ultratb.py", line 1240, in structured_traceback self, etype, value, tb, tb_offset, number_of_lines_of_context)

File "C:\Users\pauldufosse\Anaconda\lib\site-packages\IPython\core\ultratb.py", line 1157, in structured_traceback self, etype, value, elist, tb_offset, number_of_lines_of_context

File "C:\Users\pauldufosse\Anaconda\lib\site-packages\IPython\core\ultratb.py", line 509, in structured_traceback out_list.extend(self._format_list(elist))

File "C:\Users\pauldufosse\Anaconda\lib\site-packages\IPython\core\ultratb.py", line 547, in _format_list item += ' %s\n' % line.strip()

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 19: ordinal not in range(128)

1
  • We will need to see the file. Commented Jul 22, 2015 at 9:33

1 Answer 1

0

That unicode conversion problem in ultratb is obscuring whatever the original exception was that ultratb is trying to display.

Judging by the examples around, you can tell pandas.read_excel what encoding to use by passing e.g. encoding="utf-8" as you would with read_csv.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.