If you don't know which are your file encoding, I think that the fastest approach is to open the file on a text editor, like Notepad++ to check how your file are encoding.

Then you go to the python documentation and look for the correct codec to use.

In your case , ANSI, the codec is 'mbcs', so your code will look like these

df_a = pd.read_csv('file.csv',sep=';',encoding='mbcs')
Answer from rflmorais on Stack Overflow
🌐
GitHub
github.com › geopandas › geopandas › issues › 3016
BUG: ANSI and UTF-8 in same file · Issue #3016 · geopandas/geopandas
September 14, 2023 - I had the problem for some files, that write the file with geopandas to a geopackage and than open it in the next programm with geopandas I get the utf-8 error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 25: inv...
Author: geopandas
Discussions

Bug: On Python 3 to_csv() encoding defaults to ascii if the dataframe contains special characters.
I can only read test2.csv when I explicitely state encoding='ansi', so read_csv() definitely expects utf-8. More on github.com
🌐 github.com
11
July 27, 2017
python - Pandas df.to_csv("file.csv" encode="utf-8") still gives trash characters for minus sign - Stack Overflow
You can read here for a way to set your encoding that may work as a temporary solution. ... Yes I think that will have to do. I am scared to update to Python 3 in the middle of a project anyway. ... Your "bad" output is UTF-8 displayed as CP1252. On Windows, many editors assume the default ANSI ... More on stackoverflow.com
🌐 stackoverflow.com
February 2, 2021
python - Pandas- enabling ANSI encoding for read excel - Stack Overflow
Excel files are binary, they never had codepages or encodings. xlsx files are ZIP packages containing XML files. Why are you asking this? What's the actual problem you want to solve? ... Also UTF-8 is completely backward compatible with ANSI. More on stackoverflow.com
🌐 stackoverflow.com
python - ANSI Encoding for pandas on Google Colab? - Stack Overflow
ANSI is a superset of ISO-8859-1 ... work for ANSI files. Details: over here ... Sign up to request clarification or add additional context in comments. ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... 1 Python Pandas in colab:UnicodeDecodeError: 'utf-8' codec can't ... More on stackoverflow.com
🌐 stackoverflow.com
June 6, 2020
🌐
py4u
py4u.org › blog › python-pandas-load-csv-ansi-format-as-utf-8
How to Load ANSI CSV Files as UTF-8 in Python Pandas: Fixing UnicodeDecodeError with Special Characters (ä, ö, ü, ß)
The key conflict: Pandas’ pd.read_csv() defaults to encoding='utf-8'. If your CSV uses Windows-1252 (ANSI), Pandas will misinterpret the 1-byte special characters as UTF-8 bytes, leading to UnicodeDecodeError.
Author: pandas-dev
🌐
YouTube
youtube.com › the debug zone
Python pandas load csv ANSI Format as UTF-8 - YouTube
python: Python pandas load csv ANSI Format as UTF-8Thanks for taking the time to learn more. In this video I'll go through your question, provide various ans...
Published: August 7, 2024
Views: 11
🌐
Saturn Cloud
saturncloud.io › blog › a-list-of-pandas-readcsv-encoding-options
A List of Pandas readcsv Encoding Options | Saturn Cloud Blog
May 1, 2026 - UTF-8 is the most widely used encoding format for text data. It supports all characters in the Unicode standard and is compatible with ASCII. To specify UTF-8 encoding in Pandas, use the encoding='utf-8' parameter.
🌐
DEV Community
dev.to › _aadidev › 3-ways-to-handle-non-utf-8-characters-in-pandas-242
3 Ways to Handle non UTF-8 Characters in Pandas - DEV Community
January 20, 2022 - Pandas, by default, assumes utf-8 encoding every time you do pandas.read_csv, and it can feel like staring into a crystal ball trying to figure out the correct encoding.
Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 74363534 › pandas-enabling-ansi-encoding-for-read-excel
python - Pandas- enabling ANSI encoding for read excel - Stack Overflow
@topsail: no. UTF-8 is not completely backward compatible: a code point above 127 is encoded with two bytes in UTF-8 and one byte in the wrongly called "ANSI encoding".
🌐
Dasboardai
dasboardai.com › blog › how-do-i-fix-an-unicode-error-in-python
How to fixed Encoding errors in pandas - DasBoardai.com
The UnicodeDecodeError typically arises when the file's encoding doesn't match the expected UTF-8 format. Thankfully, this problem can be resolved by trying alternative encodings such as ISO-8859-1, ASCII, or even identifying the file's encoding using tools like chardet.
🌐
Quantum Tunnel
jrogel.com › python-3-pandas-encoding-issues
Python 3, Pandas and Encoding Issues – Quantum Tunnel
August 1, 2022 - You should in principle pass a parameter to pandas telling it what encoding the file has been saved with, so a more complete version of the snippet above would be: import python as pd df = pd.read_csv('myfile.csv', encoding='utf-8')
🌐
Quora
quora.com › How-do-I-fix-a-Unicode-error-while-reading-a-CSV-file-with-a-pandas-library-in-Python-3-6
How to fix a Unicode error while reading a CSV file with a pandas library in Python 3.6 - Quora
Answer (1 of 6): import pandas as pd dataset=pd.read_csv(“Your_filename.csv”, encoding=”ISO-8859–1”) This will solve the UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 16: invalid start byte Happy Learning !!!
🌐
Asana
forum.asana.com › english forum › developers & api
Encoding when exporting in CSV - Developers & API - Asana Forum
October 14, 2022 - Hi ! I’m trying to run a script to format the CSV file into a good looking Excel via python. Sometimes when exporting, it exports the file with a UTF-8 encoding and sometimes in a ANSI encoding. That mess with my code. Does anyone have a solution to make it that it always exports in a UTF-8 ...
🌐
Medium
medium.com › @anala007 › dealing-with-the-unicodedecodeerror-in-pandas-when-reading-csv-files-edc4987bf68b
Dealing with the UnicodeDecodeError in Pandas When Reading CSV Files | by Arun | Medium
June 12, 2023 - Some encodings are more flexible than others. For example, “utf-8-sig” is a variant of UTF-8 that is more tolerant of certain types of errors: import pandas as pd df = pd.read_csv('file.csv', encoding='utf-8-sig')
🌐
Pandas
pandas.pydata.org › docs › search.html
Search - pandas 3.0.2 documentation
Created using Sphinx 9.0.4 · Built with the PyData Sphinx Theme 0.16.1
🌐
Finxter
blog.finxter.com › home › learn python blog › python csv to utf-8
Python CSV to UTF-8 - Be on the Right Side of Change
August 7, 2022 - The no-library approach to convert a CSV file to a CSV UTF-8 file is to open the first file in the non-UTF-8 format and write its contents back in an UTF-8 file right away. You can use the open() function’s encoding argument to set the encoding of the file to be read. with open('my_file.csv', 'r', encoding='ANSI', errors='ignore') as infile: with open('my_file_utf8.csv', 'w') as outfile: outfile.write(infile.read())