Start New Discussion within our Software Development Community

so I have a script that is taking input from a text file and using it to populate an excel spreadsheet. it keeps giving me a UnicodeDecodeError, dying on the ± symbol, I'm assuming its not in the codec that is being used:

im using the xlwt package for writign to excel.
  File "C:\Python25\lib\site-packages\xlwt\", line 634, in save, self.get_biff_data())
  File "C:\Python25\lib\site-packages\xlwt\", line 609, in get_biff_data
    shared_str_table   = self.__sst_rec()
  File "C:\Python25\lib\site-packages\xlwt\", line 571, in __sst_rec
    return self.__sst.get_biff_record()
  File "C:\Python25\Lib\site-packages\xlwt\", line 53, in get_biff_record
  File "C:\Python25\Lib\site-packages\xlwt\", line 66, in _add_to_sst
    u_str = upack2(s, self.encoding)
  File "C:\Python25\Lib\site-packages\xlwt\", line 50, in upack2
    us = unicode(s, encoding)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb1 in position 59: ordinal not in range(128)

I've tried to encode it but unsure which codec to use. any recommendations for how to handle it?

the code that dies is when it saves the workbook with that symbol in the line

This article has been dead for over six months. Start a new discussion instead.