Search code examples
pythonpandasxlsx

'utf-8' codec can't decode using pandas and reading xlsx


I'm trying read a xlsx file in python with padas but i get this:

'utf-8' codec can't decode byte 0xc9 in position 6: invalid continuation byte

import pandas as pd
data = pd.read_excel(r'C:\Users\nlsouza\Desktop\teste3.xlsx')
query = data['Final'].values.tolist()

Solution

  • You are probably trying to read an excel file containing special characters (Russian Symbols ... ).

    You should add a parameter to your read_excel :

    df=pd.read_excel(r'C:\Users\nlsouza\Desktop\teste3.xlsx',encoding='utf-8')
    

    Hope it'll work for you