0

I'm trying to use one csv file using csv.reader and facing issue in decoding unicode character, tried all possible ways. here is my code-

 def get_input_dup(path):
            with open(path, 'r', encoding='utf-8') as f:
                reader = csv.reader(f)
                sentence_pairs = list(reader)
            #print(data)
            return sentence_pairs

this is the error message "return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 16: character maps to " any help is appreciated.

9
  • Are you on Python 2 or 3? Commented Apr 26, 2017 at 5:00
  • @burhanKhalid I'm using python 3.4. Commented Apr 26, 2017 at 5:10
  • try using pandas.read_csv(). it handles most data well Commented Apr 26, 2017 at 5:12
  • are you sure about Python 3.4? Are you sure your file is actually utf-8 and not something else? Commented Apr 26, 2017 at 5:14
  • Are you sure that the file from which you are reading is encoded as utf-8 rather than something else? I've had issues with files encoded as e.g. latin or with a BOM. Commented Apr 26, 2017 at 5:41

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.