1

I'm trying to read a csv file using python on jupyter notebook using the following command:

data = pandas.read_csv("/Users/noha/Desktop/SongCSV.csv")

However, I keep getting this error:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xed in position 5: invalid continuation byte

I don't understand why this is happening.

Adrian Mole
  • 49,934
  • 160
  • 51
  • 83
user130996
  • 71
  • 1
  • 4
  • 2
    There's invalid encoding in the file. – Barmar Mar 17 '19 at 08:55
  • Can you post csv file too ? – num3ri Mar 17 '19 at 08:58
  • Your CSV file is not UTF-8. What program did you create it with? If it was a program like Excel on Windows, CP-1252 is a reasonable encoding to try. But fundamentally you need to know the encoding before you can read *any* text file, whether CSV or anything else. – Daniel Pryden Mar 17 '19 at 10:51
  • Please, see this: https://stackoverflow.com/questions/54455487/python-failure-on-output-redirect-pipe/54455794#54455794 I think it may be useful. – num3ri Mar 17 '19 at 11:00

1 Answers1

-1

If you mention the encoding it will be solve:

import pandas as pd
data = pd.read_csv('/Users/noha/Desktop/SongCSV.csv', encoding='utf-8')

If face any problem comment below

Shariful Islam
  • 526
  • 3
  • 10