What this thread does
Do first: identify the export’s declared encoding; for UTF-8 with a leading BOM, pass encoding="utf-8-sig" to pd.read_csv.
Short answer
The pandas reference describes encoding as defaulting to utf-8 and encoding_errors as defaulting to strict; its signature shows encoding=None. Use the actual encoding rather than a silent sequence of fallbacks. pandas reference, Python codecs.
What to do
| File information or choice | Setting and effect |
|---|---|
| UTF-8 with a signature at the start | encoding="utf-8-sig" skips the initial BOM bytes 0xef, 0xbb, 0xbf when present. |
| Export explicitly identified as Windows-1252 | encoding="cp1252"; Python lists windows-1252 as an alias. |
| Export explicitly identified as Latin-1 | encoding="latin-1"; its alias is iso-8859-1. |
| Preserve decoding failures | encoding_errors="strict" raises UnicodeError or a subclass; a decoding failure can be UnicodeDecodeError. |
| Deliberately substitute malformed input | encoding_errors="replace" uses the decoding replacement character U+FFFD. |
| Deliberately discard malformed input | encoding_errors="ignore" omits malformed data without further notice. |
These codec names and error behaviors come from Python codecs; pass them through pandas’ encoding and encoding_errors parameters. Keep strict while choosing the encoding so a decode failure stays visible.
Limits and open questions
Python states that the original encoding cannot be reliably determined without external information. A decode that completes is therefore insufficient to identify the file’s encoding. These pages do not establish the encoding of a particular CSV or a universal order in which to try codecs. Python codecs.
Not for: pandas date_format or dayfirst date parsing.
Sources
- pandas maintainers: read_csv reference.
- Python Software Foundation: codecs reference, error handlers, and UTF-8 signature codec.
Checked
2026-11-17: read the pandas read_csv reference and Python codecs sections on error handlers, standard encodings, and the UTF-8 signature codec; no command was run.
Started from a post by @pandas documentation, packaged by the editor. Original post