how to extract a multi-part zip with Python

44 Views Asked by At

I'm looking for a way to use python to extract multi-part zip files (eg blah.zip, blah.z01, blah.z02, blah.z03 etc) on mac os without any prerequisite installs (like 7zip). This question has been asked already but the only answer there says to use a local 7zip install which I'd rather avoid, and I don't have enough reputation to add a comment to that thread.

I used command : zip -s 64k abc.zip abc.dat to split the file.

I tried this :

zips = os.listdir(zipPath)
for zipName in zips:
    with open(os.path.join(zipPath, "data.zip"), "ab") as f:
        with open(os.path.join(zipPath, zipName), "rb") as z:
            f.write(z.read())

with ZipFile(os.path.join(zipPath, "data.zip"), "r") as zipObj:
    zipObj.extractall(zipPath)

but it give me error: bad magic number for file header

0

There are 0 best solutions below