Questions tagged [python-zipfile]

Python standard-library module provides tools to create, read, write, append, and list a ZIP file.

404 questions
0
votes
1 answer

How to add a bunch of images to a zipfile

I have a list of image filenames with about 150 entries. Every image is downloaded via urllib and stored on the system. The result is a zipfile containing several broken images. The last part of some images is missing / corrupt. The image download…
0
votes
1 answer

Create individual archives from individual folders with Zipfile

I have a directory composed of 3 folders : ----- 001 ----- 002 ----- 003 I'd like to create 3 archives named 001.zip, 002.zip and 003.zip. Each archive has to be composed of the content of the folder. I use the zipfile library and I managed to make…
Julien
  • 699
  • 3
  • 14
  • 30
0
votes
2 answers

Get Local File name after ZipFile extract()

How do I get the local file name after ZipFile extract() runs? When I do this: with zipfile.ZipFile(localZipFilePath, "r") as zf: for name in zf.namelist(): localFilePath = zf.extract(name, '/tmp/') print…
Be Kind To New Users
  • 9,672
  • 13
  • 78
  • 125
0
votes
1 answer

Python and the zipfile module

According to Python documentation: ZipFile.extract(member[, path[, pwd]]) Extract a member from the archive to the current working directory; member must be its full name or a ZipInfo object). Its file information is extracted as accurately as…
Alex
  • 3
  • 2
0
votes
1 answer

Prevent zipfile writing directory to archive

I have the below to zip a file. the file zips correctly, but contains the folders within the zip. How can I just zip the file, whilst still being able to show where the file is located? create_zip_path =…
0
votes
1 answer

Python zipfile whole path is in file

I'm using the code from here to make a zip file from a directory. I give the function an absolute path to a folder from a GUI. Currently, say the path is c:\users......, the zip folder structure is users...... . How can I remove the absolute path…
user2290362
  • 717
  • 2
  • 7
  • 21
0
votes
1 answer

ImportError: No module named 'zipFile'

I am running python on windows in sublime text. When i wanted to work with the zipfile module I get this error ImportError: No module named 'ZipFile'. I tried changing the name to zipfile from Zipfile with no success. I looked at my pythonpath…
Darshan
  • 57
  • 1
  • 1
  • 7
0
votes
1 answer

How to list a folder's files using the zipfile module in Python

I'm having a .zip file which contains lots of files and directories in it. Its structure resembles the following sketch. / contents/ --file1.txt --file2.txt lists/ --file3.txt --file4.txt file5.txt file6.txt I am currently interested on…
stratis
  • 7,750
  • 13
  • 53
  • 94
0
votes
1 answer

Python appending to ZipFile with file-object even with 'a' mode truncates file

I create an open file like this: self.file = open(self.gamefile, 'ab') Then, I write to it twice, with the ZipFile object. with zipfile.ZipFile(self.file, 'a', zipfile.ZIP_DEFLATED) as zipf: zipf.writestr("file1.mcw", pickle.dumps(world)) with…
Name McChange
  • 2,750
  • 5
  • 27
  • 46
0
votes
1 answer

how to use python zipfile to append comment for a zip file?

$ echo "short"|zip -z test.zip enter new zip file comment (end with .): $ md5sum test.zip 48da9079a2c19f9755203e148731dae9 test.zip $ echo "longlong"|zip -z test.zip current zip file comment is: short enter new zip…
benny
  • 1
  • 2
0
votes
1 answer

Python zipfile library fix

I've got a problem. I've made a simple zip file with password 12345. Now, when I try to extract the password using brute-force, zipfile chooses wrong password. It says it found password aaln0, but the extracted file is completly empty. Is there a…
JadedTuna
  • 1,783
  • 2
  • 18
  • 32
0
votes
1 answer

Extract a zip file in python [zip file contains .img file in it, and zipfile gets stuck]

I am trying to extract a .zip file using python. I am doing it as: z = zipfile.ZipFile(file_name) for f in z.namelist(): print f if f.endswith('/'): os.makedirs(f) else: z.extract(f) This works fine until the .img file…
Destructor
  • 3,154
  • 7
  • 32
  • 51
0
votes
1 answer

Python zipfile, bizarre limit to number of files: "folder is invalid"

The computer is toying with me, I know it! I am creating a zip folder in Python. The individual files are generated in memory and then the whole thing is zipped and saved to a file. I am allowed to add 9 files to the zip. I am allowed to add 11…
user984003
  • 28,050
  • 64
  • 189
  • 285
0
votes
1 answer

Add a file to a jar using python zipfile

I need to add a file to jar but when i run the program zipfile delete all file and add a file. but i need the other files! my code: (this is a test) import zipfile m= zipfile.ZipFile("test.jar","w") m.write("test.jar","bgt.class") m.close()
SergiX44
  • 371
  • 2
  • 5
  • 15
0
votes
2 answers

Why are some files are not being added do my zipfile

I have the following code: with ZipFile('deploy.zip', 'w') as deploy: if os.path.isfile(artifact.source): deploy.write(artifact.source, artifact.target) else: for base, dirs, files in os.walk(artifact.source): for…
Giuliani Sanches
  • 650
  • 5
  • 20
1 2 3
26
27