0

I tried importing a medical data and I ran into this unicode error, here is my code:

output_path = r"C:/Users/muham/Desktop/AI projects/cancer doc classification"
my_file = glob.glob(os.path.join(output_path, '*.csv'))

for files in my_file:
data = pd.read_csv(files)
   print(data)

My error:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0x93 in position 3314: invalid start byte
  • The initial data is not encoded in UTF-8, so you should explicitly add the encoding – Giacomo Catenazzi Sep 12 '22 at 15:40
  • Does this answer your question? [UnicodeDecodeError when reading CSV file in Pandas with Python](https://stackoverflow.com/questions/18171739/unicodedecodeerror-when-reading-csv-file-in-pandas-with-python) – Joachim Sauer Sep 12 '22 at 15:40

1 Answers1

0

Try other encodings, default one is utf-8

like

import pandas

pandas.read_csv(path, encoding="cp1252")

or ascii, latin1, etc ...

Devyl
  • 565
  • 3
  • 8