Error reading file . xls

Asked

Viewed 225 times

0

I have some files to read in Python, I’m using the following structure:

df = pd.read_csv(path, Sep=' t')

And this generated the following error:

Unicodedecodeerror: 'utf-8' codec can’t Decode byte 0xc3 in position 9: Unexpected end of data

Searching the internet, I added an engine='python' (df = pd.read_csv(path, engine='python', Sep=' t')) and it read normally, I thought my problems were over, but when I went to read the other files, the following error happened:

Using encoding = 'ISO-8859-1' also solved in the first case, but in the other files was the following:

inserir a descrição da imagem aqui

pandas.errors.Parsererror: NULL byte Detected. This byte cannot be processed in Python’s Native csv library at the Moment, so Please pass in engine='c' Instead

Visually, both files are equal, same data type, same size virtually, same extension. Does anyone know the pq of this incompatibility?

1 answer

2

If you have an "XLS" file with in the issue title, it will not be able to be read with functions to read "CSV" files. They are fundamentally different files. (And CSV files usually won’t have bytes " x00" inside - so I really think it’s an Excel file).

If it’s a file .xlsx, Pandas has the function read_excel which you can use. If it is a legacy spreadsheet ". xls", your options will be to install another Python library to access the data, and then convert them to a dataframe, or open in Excel and save in another format.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.