0

Here is the code. Super straightforward.

df = pd.read_csv('Superstore-Sales.csv')
df

But I am getting the following error

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xae in position 16: invalid start byte

I've never had this error when doing this before.

Any thoughts on a fix? Is there something I'm missing?

I've tried adding unicode= 16 as a perameter. No luck there.

Josh Bennett
  • 39
  • 1
  • 10
  • This is already answered check the link below https://stackoverflow.com/questions/18171739/unicodedecodeerror-when-reading-csv-file-in-pandas-with-python – My3 Mar 26 '18 at 03:48
  • Nice!! That did the trick. I hadn't found that thread. – Josh Bennett Mar 26 '18 at 03:55

1 Answers1

0

Try the following:

import pandas as pd
df = pd.read_csv('file_name.csv', encoding='utf-8')

If the above doesn't work, then do the following:

  • Open the csv file in Sublime text editor.
  • Save the file in utf-8 format.
  • In Sublime, Click File -> Save with encoding -> UTF-8

Then you can read the file as usual,

import pandas as pd
df = pd.read_csv('file_name.csv', encoding='utf-8')
Gil Baggio
  • 13,019
  • 3
  • 48
  • 37