I am trying to read csv files using pd.read_csv. I am running into encoding issues and I’m not sure how to proceed. The first issue I running into is the following error message caused when reading csv fiels that contain a µ character.
“SyntaxError: Non-UTF-8 code starting with '\xb5' in file GUI_Simpilify.py on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details”
I’m able to get past this error by manually changing the file name and removing the µ. However, this is not a solution as I have 1,000’s of csv files to extract data from.
Once I manually remove the µ from a single csv file and rerun my script I get this error message: “UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb1 in position 13: invalid start byte”
I believe this is due to the fact that all of my csv files contain both ± and µ characters. How can I deal with both these errors without manual solutions?
Code:
import pandas as pd
test_csv = pd.read_csv('OFN 0.1pg_L Split 20-1 (5 fg on column).csv')