0

There are a lot of topics and suggestions concerning this type of error but nothing has worked for me. You can find a part of my code below:

import sys
import codecs
import csv

with codecs.open('Info Dataset.csv', 'r') as csvf:
    reader = csv.reader(csvf)
        reader = list(reader)

I have tried solutions like:

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

as also to add to my path the variable PYTHONIOENCODING=UTF-8 but nothing of these fixed the problem. Is there anything else i could try effectively ?

HELMA
  • 19
  • 4
  • In Python 2, `csv.reader()` expects **bytestrings**. You can't use `codecs.open()` to pass it Unicode instead. How to combine the `csv` module with Unicode data is covered explicitly in the module documentation, or see the duplicate. – Martijn Pieters Dec 05 '17 at 10:00
  • Side note: **never** use the `sys.setdefaultencoding()` crutch. It is a cargo-culting 'solution' that can actually cause more issues down the line. – Martijn Pieters Dec 05 '17 at 10:00

0 Answers0