Reputation: 438
I have files in bucket of s3 and i am reading them as stream. I want to detect the encoding of the diffrent files.
I used chardet library , i am getting this error:
TypeError: Expected object of type bytes or bytearray, got: <class
'botocore.response.StreamingBody'>
and my code is:
a = (obj.get()['Body'])
reader = chardet.detect(a).get('encoding')
print(reader)
And is there any other ways to detect the encoding before opening of a file
Upvotes: 0
Views: 647
Reputation: 438
i got this
you need to use read function again!
a = (obj.get()['Body']._raw_stream).read()
Upvotes: 0