. Advertisement .
. Advertisement .
Guido van Rossum invented Python, a brave, powerful, high-level user-object-oriented programming language. It is easily accessible and is quickly emerging as one of the greatest introductory programming languages for beginners.
When you try to do something in Python software, you get the following message:
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x96 in position 35: invalid start byte
Please don’t get too worked up about it. This section will describe how to address these issues with this widely used program.
When May The Problem “UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x96 in position 35: invalid start byte” Appear?
You’re attempting to read your CSV file and face a new error like this.
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 35: invalid start byte
The Three Top Efficient Methods
You can try one of the three most popular solutions listed below to resolve this issue.
In the first method, you need to use the encoding=”ISO-8859-1″. Here is an example for you.
pd.read_csv("Your filename", encoding="ISO-8859-1")
Now, you can use the encoding cp1252 in this second tip, and your issue will be resolved. Use the below example if you are using Windows.
The last approach is so simple for all readers to tackle this solution, and it would ignore errors.
with open(path, encoding=”utf8″, errors=’ignore’) as f:
Utilizing this solution means that its characters would be stripped out (ignored), and even the string would be returned without them. Use this if you need to strip them rather than convert them.
Using mistakes=’ignore’ and you’ll only lose a few characters. However, disregard them if you are not even concerned about them because they appear to be additional characters arising from the poor formatting or coding of the customers connecting to the socket server. Then there is a simple direct remedy.
At last, the three methods listed above are simple fixes for the aforementioned severe flaw: “UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x96 in position 35: invalid start byte“.
Also, if you have any additional suggestions, kindly leave them in the comments section. Now, we wish everybody the best of luck with the Python program.