#๐Ÿ”’ Trouble reading specific Zip file

18 messages ยท Page 1 of 1 (latest)

crisp prairie
#

So, here's what's going on, I am making a script which retrieves icons from APK files, and it reads most of them fine, but for one of them, despite having the same header as the other ones, zipfile.is_zipfile() returning true and other file managers being able to read it, python's zipfile.ZipFile library raises zipfile.BadZipFile: Bad magic number for file header when attempting to extract this file.

small hemlockBOT
#

@crisp prairie

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

crisp prairie
#

It doesn't let me attach the file here, but I will gladly answer any questions.

#

But as per what this random website I found says, there appears to be nothing wrong with the file

#

What confuses me even more is that the pyaxmlparser library I use to analyze the APKs is fine with it, unless I use it to extract the icon, then it raises the same exception

crisp prairie
#

Oh, wait, wrong zip, this one's the problematic one

livid fjord
#

There is no context that can allow some one to troubleshoot this error...

Please provide your code and the terminal output (including the full exception error).

#

!paste

small hemlockBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

sweet sigil
#

quick and dirty solution if only one file is erroring is to do this one by hand

crisp prairie
crisp prairie
#

This isn't the exact code I used because I iterate through a directory in the actual script among many other functions, but this should produce the same result, if the APK file were present.

#

Everything except the icon reads fine so I'm thinking I'll use a try except when fetching the icon if this can't be fixed, it's not the most necessary thing

hollow surge
#

can you upload it somewhere else?

#

or where did you get it from? did you create it yourself?

small hemlockBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.