0

I have these lines of code:

zf = zipfile.ZipFile(self.temp_file, 'r')
data = zf.open('myfile.csv', mode='r')
result = [link for link in unicodecsv.DictReader(data)]

And here's the exception code:

UnicodeDecodeError: 'utf8' codec can't decode byte 0xc9 in position 13: invalid continuation byte

Input string is:

CAFÉ RESTAURANT

So what am I doing wrong and why unicodecsv can't handle utf-8?

1
  • because the content is not UTF-8. Commented Apr 6, 2015 at 19:05

1 Answer 1

3

It is because your input is not UTF-8, but Latin-1 (or similar). In UTF-8, É is encoded as 2 bytes: '\xc3\x89'. The error informs that the \xc9 byte was met in the input; this is És encoding in Latin-1 or Win-1252 codepages.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.