<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
This is the original full traceback. when I was getting the Unicode Decode Error..<BR>
 <BR>
<STRONG>Traceback (most recent call last):<BR>  File "C:\Documents and Settings\pkhemka\My Documents\merge_py.py", line 315, i<BR>n <module><BR>    wbk.save('p4_merge.xls')<BR>  File "C:\Python25\lib\site-packages\xlwt\Workbook.py", line 634, in save<BR>    doc.save(filename, self.get_biff_data())<BR>  File "C:\Python25\lib\site-packages\xlwt\Workbook.py", line 609, in get_biff_d<BR>ata<BR>    shared_str_table   = self.__sst_rec()<BR>  File "C:\Python25\lib\site-packages\xlwt\Workbook.py", line 571, in __sst_rec<BR>    return self.__sst.get_biff_record()<BR>  File "C:\Python25\Lib\site-packages\xlwt\BIFFRecords.py", line 53, in get_biff<BR>_record<BR>    self._add_to_sst(s)<BR>  File "C:\Python25\Lib\site-packages\xlwt\BIFFRecords.py", line 66, in _add_to_<BR>sst<BR>    u_str = upack2(s, self.encoding)<BR>  File "C:\Python25\Lib\site-packages\xlwt\UnicodeUtils.py", line 50, in upack2<BR>    us = unicode(s, encoding)<BR>UnicodeDecodeError: 'ascii' codec can't decode byte 0x92 in position 152: ordina<BR>l not in range(128)</STRONG><BR>
 <BR>
I tried to solve it using this <STRONG>wbk = xlwt.Workbook('utf-8')... </STRONG>The problem still persists. Is there a way I can solve this problem..?<BR>
<BR><STRONG>Traceback (most recent call last):<BR>  File "C:\Documents and Settings\pkhemka\My Documents\merge_py.py", line 229, i<BR>n <module><BR>    sheet.write(x,4,Technical_detail,datastyle)<BR>  File "C:\Python25\Lib\site-packages\xlwt\Worksheet.py", line 1003, in write<BR>    self.row(r).write(c, label, style)<BR>  File "C:\Python25\Lib\site-packages\xlwt\Row.py", line 231, in write<BR>    StrCell(self.__idx, col, style_index, self.__parent_wb.add_str(label))<BR>  File "C:\Python25\lib\site-packages\xlwt\Workbook.py", line 306, in add_str<BR>    return self.__sst.add_str(s)<BR>  File "C:\Python25\Lib\site-packages\xlwt\BIFFRecords.py", line 24, in add_str<BR>    s = unicode(s, self.encoding)<BR>UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 152: unexpec<BR>ted code byte<BR></STRONG><BR>
<HR id=stopSpelling>
From: ian.g.kelly@gmail.com<BR>Date: Fri, 8 Oct 2010 16:59:19 -0600<BR>Subject: Re: Unicode Decode Error<BR>To: python-list@python.org<BR><BR>
<DIV class=ecxgmail_quote>On Fri, Oct 8, 2010 at 3:31 PM, Pratik Khemka <SPAN dir=ltr><<A href="mailto:pratikkhemka@hotmail.com">pratikkhemka@hotmail.com</A>></SPAN> wrote:<BR>
<BLOCKQUOTE class=ecxgmail_quote style="PADDING-LEFT: 1ex">
<DIV><B><I><U>UnicodeDecodeError: 'ascii' codec can't decode byte 0x92 in position 152: ordinal not in range(128)</U></I></B>. Can someone please help me with  this error<BR>The error occurs in line <B><I><U>wbk.save(p4_merge.xls)</U></I></B>. I have used <B><I><U>import xlwt</U></I></B>..Can someone just tell what do I need to do to get rid of this error. I read other forums which explain the error but do not solve it. Thanks in advance..<BR></DIV><BR></BLOCKQUOTE></DIV><BR>You're writing non-ascii data to the workbook, which is then trying to decode it using the default ascii encoding, which will fail.  When you create the workbook, you need to specify the correct encoding, e.g.:<BR><BR>wbk = xlwt.Workbook('utf-8')<BR><BR>or whatever encoding you're actually using.<BR><BR>Cheers,<BR>Ian<BR><BR>-- http://mail.python.org/mailman/listinfo/python-list                                    </body>
</html>