Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 UTF-8 decoder reports bad byte that is not there
#1
i am getting the error:

Output:
Traceback (most recent call last): File "/home/pdh/aptdata.py", line 233, in <module> result=main(argv) File "/home/pdh/aptdata.py", line 206, in main loadinfo(f,data) File "/home/pdh/aptdata.py", line 123, in loadinfo for line in file: File "/usr/lib/python3.5/codecs.py", line 321, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte
but there is no byte 0x8b anywhere in the whole file. what should i do about this?

the file is one of the files Ubuntu's package management works with. the name of the file is /var/lib/apt/lists/security.ubuntu.com_ubuntu_dists_xenial-security_main_binary-amd64_Packages. i have added diagnostic output to the code and appears that the problem is happening just before EOF. the last 2 bytes of the file are 0x0a and 0x0a (an empty line at the end. the is iterating over the lines in the file with for line in file: and every line of the file has been iterated. it's like the utf-8' codec is making this up. maybe some lower level i/o code is leaving garbage in a buffer.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  'utf-8' codec can't decode byte 0xda in position 184: invalid continuation byte karkas 7 283 Sep-12-2019, 11:19 PM
Last Post: newbieAuggie2019
  Python for Reports in HTML or PDF Format ImPyBoy17 1 563 Dec-10-2018, 09:35 PM
Last Post: j.crater
  Generate PDF reports giu88 7 1,841 Aug-26-2018, 02:00 PM
Last Post: giu88
  Start checking for geology reports tjnichols 1 627 Jun-04-2018, 08:55 PM
Last Post: Larz60+
  4 byte hex byte swap from binary file medievil 7 6,139 May-08-2018, 08:16 AM
Last Post: killerrex
  MP4 decoder jdewk 4 1,615 Jan-13-2018, 10:02 PM
Last Post: jdewk
  JSON Decoder issue Cronax3 2 4,941 Sep-13-2017, 09:23 AM
Last Post: Cronax3
  Best software for creating printed reports? birdieman 5 1,589 Feb-02-2017, 02:39 AM
Last Post: birdieman
  Reports with Python? panoss 1 1,131 Jan-11-2017, 10:33 PM
Last Post: micseydel

Forum Jump:


Users browsing this thread: 1 Guest(s)