solve unicodedecodeerror: 'utf-8' codec can't decode byte 0x80 in position 3131: invalid start byte python3 code example

Example 1: UnicodeDecodeError: 'utf-8' codec can't decode byte invalid start byte

# Use 'ISO-8859-1' instead of "utf-8" for decoding
text = open(fn, 'rb').read().decode('ISO-8859-1')

Example 2: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe7 in position 5: invalid continuation byte

pd.read_csv('ml-100k/u.item', sep='|', names=m_cols , encoding='latin-1')

Tags:

Misc Example