2

I have a problem when I try to read a csv file :

# Load satisfaction table     
client = boto3.client('s3') #low-level functional API

resource = boto3.resource('s3') #high-level object-oriented API
my_bucket = resource.Bucket('bucket1') #subsitute this for your s3 bucket name. 
obj = client.get_object(Bucket='bucket1', Key='file.csv')
data = pd.read_csv(io.BytesIO(obj['Body'].read()), delimiter=',',engine='python', encoding='utf-8')

I get this error :

UnicodeDecodeError: 'utf8' codec can't decode byte 0x96 in position 76: invalid start byte

Any idea please?

Thank you

Nasri
  • 525
  • 1
  • 10
  • 22
  • Use a different encoding? (the one that the *.csv* file has the text encoded with) – CristiFati May 09 '18 at 17:04
  • Possible duplicate of [Python : UnicodeDecodeError: 'utf-8' codec can't decode byte 0x96 in position 35: invalid start byte](https://stackoverflow.com/questions/45529507/python-unicodedecodeerror-utf-8-codec-cant-decode-byte-0x96-in-position-35) – Alex B Jul 29 '18 at 22:50
  • In my case the file was gzipped. – Andrei Apr 24 '19 at 11:04

1 Answers1

0

Ran into the problem:

On OSx, solved by deleting

.aws

folder under userprofile. Seems like boto3 calls contents of .aws folder.

Merlin
  • 24,552
  • 41
  • 131
  • 206