2

I have a CSV file and when I try to read it in Python 2.7, it makes following error.

UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 10: ordinal not in range(128)

This is my code so far,

with open('train.csv', 'rb') as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
    text=(row['Descript'])
    emotion = (row['Category'])

I found many solution from this site like How to fix: "UnicodeDecodeError: 'ascii' codec can't decode byte", UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 1 But they are not able to fix my error. Can anyone help me.

Chathuri Fernando
  • 950
  • 3
  • 11
  • 22

0 Answers0