UnicodeDecodeError: 'utf8' codec can't decode byte 0x98

1,080 views
Skip to first unread message

Valentina

unread,
Apr 11, 2013, 5:30:13 AM4/11/13
to bots...@googlegroups.com
Hi,

I've problem with charset. My infile is a xlsx with charset iso8859-1. I've defined the charset in the grammar. 

syntax = {
   
'noBOTSID'   : True,             #does not have record-ID's
   
'skip_firstline':True,
   
'decimaal': '.',
   
'charset':'iso8859-1'
 
}


But I get the error. What is wrong? 


Traceback (most recent call last): File "C:\Python27\lib\site-packages\bots\transform.py", line 65, in translate idroute=idroute) File "C:\Python27\lib\site-packages\bots\inmessage.py", line 38, in parse_edi_file ediobject.initfromfile() File "C:\Python27\lib\site-packages\bots\inmessage.py", line 56, in initfromfile self._readcontent_edifile() File "C:\Python27\lib\site-packages\bots\inmessage.py", line 269, in _readcontent_edifile self.rawinput = botslib.readdata(filename=self.ta_info['filename'],charset=self.ta_info['charset'],errors=self.ta_info['checkcharsetin']) File "C:\Python27\lib\site-packages\bots\botslib.py", line 542, in readdata content = filehandler.read() File "C:\Python27\lib\codecs.py", line 671, in read return self.reader.read(size) File "C:\Python27\lib\codecs.py", line 477, in read newchars, decodedbytes = self.decode(data, self.errors) UnicodeDecodeError: 'utf8' codec can't decode byte 0x98 in position 16: invalid start byte Thank you Valentina

henk-jan ebbers

unread,
Apr 11, 2013, 7:05:28 AM4/11/13
to bots...@googlegroups.com
hi Valentina,

might it be you are reading a excel file as a csv file?
there is a messagetype 'excel'.

that works, but I am not sure if it is documented very well.

uses python library 'xlrd'

hope that helps,
henk-jan

On 04/11/2013 11:30 AM, Valentina wrote:
> Hi,
>
> I've problem with charset. My infile is a xlsx with charset iso8859-1. I've defined the charset in the grammar.
>
> |
> syntax ={
> 'noBOTSID':True,#does not have record-ID's
> 'skip_firstline':True,
> 'decimaal':'.',
> 'charset':'iso8859-1'
> }
> |
>
>
> But I get the error. What is wrong?
>
>
> Traceback (most recent call last): File "C:\Python27\lib\site-packages\bots\transform.py", line 65, in translate idroute=idroute) File "C:\Python27\lib\site-packages\bots\inmessage.py", line 38, in
> parse_edi_file ediobject.initfromfile() File "C:\Python27\lib\site-packages\bots\inmessage.py", line 56, in initfromfile self._readcontent_edifile() File
> "C:\Python27\lib\site-packages\bots\inmessage.py", line 269, in _readcontent_edifile self.rawinput =
> botslib.readdata(filename=self.ta_info['filename'],charset=self.ta_info['charset'],errors=self.ta_info['checkcharsetin']) File "C:\Python27\lib\site-packages\bots\botslib.py", line 542, in readdata
> content = filehandler.read() File "C:\Python27\lib\codecs.py", line 671, in read return self.reader.read(size) File "C:\Python27\lib\codecs.py", line 477, in read newchars, decodedbytes =
> self.decode(data, self.errors) UnicodeDecodeError: 'utf8' codec can't decode byte 0x98 in position 16: invalid start byte Thank you Valentina
>
> --
> You received this message because you are subscribed to the Google Groups "Bots Open Source EDI Translator" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to botsmail+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Valentina

unread,
Apr 11, 2013, 8:31:42 AM4/11/13
to bots...@googlegroups.com
Hi henk-jan,

Did I need in bots 3.0 also a routescript for reading excel files ? 

Best Regards 

Valentina

henk-jan ebbers

unread,
Apr 11, 2013, 8:35:51 AM4/11/13
to bots...@googlegroups.com
no.

Valentina

unread,
Apr 11, 2013, 8:55:31 AM4/11/13
to bots...@googlegroups.com

Hi,

I've a translation with the messagetype 'excel'. I've also the 'xlrd' library, but I get the UnicodeDecodeError. Do you have somewhere a example ? 

Thank you very much 

Valentina

henk-jan ebbers

unread,
Apr 11, 2013, 9:07:48 AM4/11/13
to bots...@googlegroups.com
hi Valentine,

helas, at the moment I have very limited time.

what error message do you get?

henk-jan

Valentina

unread,
Apr 11, 2013, 9:35:39 AM4/11/13
to bots...@googlegroups.com
Hi

I've get this message:

henk-jan ebbers

unread,
Apr 11, 2013, 9:41:18 AM4/11/13
to bots...@googlegroups.com
if incoming type is excel,

it should not get there at all. (File "C:\Python27\lib\site-
packages\bots\inmessage.py", line 56, in initfromfile)

(class fro type excel has its own initfromfile)

henk-jan

Valentina

unread,
Apr 12, 2013, 8:50:43 AM4/12/13
to bots...@googlegroups.com
Hi Henk-jan

Thank you. Yes the Fromedittype of the route was not excel. 

It works now.

Best regards

Valentina

henk-jan ebbers

unread,
Apr 12, 2013, 8:55:06 AM4/12/13
to bots...@googlegroups.com
hey man, that is great!
just worked of of the box? (after that change)

henk-jan

Valentina

unread,
Apr 12, 2013, 9:32:50 AM4/12/13
to bots...@googlegroups.com
Yes it works.
Reply all
Reply to author
Forward
0 new messages