Home > front end >  Pandas read csv file error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff i
Pandas read csv file error UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff i

Time:10-05

I would like to open csv data but keep getting the same error, what can I do to succesfully open csv files using Python?

#Reading in the files
import pandas as pd
data1 = pd.read_csv("data1.csv")

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte

CodePudding user response:

byte 0xff in position 0 means that your .csv is encoded in utf-16.

Try this :

data1 = pd.read_csv("data1.csv", encoding="utf-16")
  • Related