MEHMET BALIOGLU

UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x80 in position 3131: invalid start byte

When I was trying to read csv files in Python, I came across the UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0x80 in position 3131: invalid start byte error.

When I went up to the beginning of the error message, I saw a .DS_Store file and quickly realized the culprit. There was a hidden .DS_Store file in the data directory and Python could not parse it, therefore throwing the above-mentioned error.

In order to see all the files in my directory, I used ls -la, and there it was:

When I removed it, problem solved!

#first go to the directory where .DS_Store file is located, and then:
find . -name '.DS_Store' -type f -delete