Reputation: 205
I'm trying to read an excel file with pandas (+50000 rows), and it gives me the same error in all cases. the code:
strfile='C:\\Users\\...\\excel_files\\excelfile_01.xls'
Try 01:
import pandas as pd
data = pd.read_excel(strfile, low_memory=False)
Try 02:
import pandas as pd
data = pd.read_excel(strfile, encoding='utf-16-le',low_memory=False)
Try 03:
import pandas as pd
data = pd.read_excel(strfile, encoding='sys.getfilesystemencoding()',low_memory=False)
Try 04:
import pandas as pd
data = pd.read_excel(strfile, encoding='latin-1',low_memory=False)
The error in all cases:
UnicodeDecodeError: 'utf-16-le' codec can't decode bytes in position 146-147: unexpected end of data
Any help/tip will be greatly appreciated. Thanks in advance.
Upvotes: 3
Views: 4588
Reputation: 1314
Posting my previous comment as an answer:
Try saving your legacy .xls
file in the modern .xlsx
format and send it to pd.read_excel()
Upvotes: 1