Cause 1 of 5
The file is not UTF-8 — commonly Windows-1252 or Latin-1 from a spreadsheet or legacy export.
Decode it with the encoding it actually uses: open(path, encoding='cp1252'). If you do not know, charset-normalizer or chardet will guess — treat the guess as a hypothesis and eyeball the result before running a bulk import on it.
Cause 2 of 5
The file is binary but was opened as text.
A failure at position 0 on byte 0xff, 0xfe, 0x89 or 0x50 usually means a real binary file — an image, a .xlsx, a gzip. Open it with mode 'rb' and hand it to the right library: pandas.read_excel or openpyxl for .xlsx, not open().read().
Cause 3 of 5
You relied on the platform default encoding.
open() without encoding= uses the locale encoding, which is UTF-8 on most Linux and macOS setups but has historically been cp1252 on Windows — so the same script behaves differently per machine. Always pass encoding='utf-8' explicitly.
Cause 4 of 5
The file starts with a UTF-8 byte order mark.
A BOM decodes to a stray character that breaks the first CSV header or JSON key, and shows up as a mysterious leading character in output. Open with encoding='utf-8-sig', which recognises and strips it.
Cause 5 of 5
You are scanning a large log and a few bad bytes are acceptable.
open(path, encoding='utf-8', errors='replace') substitutes a replacement character instead of raising; errors='ignore' drops the bytes. Both lose data silently, so use them for inspection and never for data you intend to store.