Questions tagged [python-zipfile]

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

404 questions
2
votes
2 answers

Listing all directories recursively within the zipfile without extracting in python

In Python we can get the list of all files within a zipfile without extracting the zip file using the below code. import zipfile zip_ref = zipfile.ZipFile(zipfilepath, 'r') for file in zip_ref.namelist(): print file Similarly is there a…
Evelyn Jeba
  • 4,181
  • 3
  • 12
  • 10
2
votes
3 answers

How to get meta-data of files inside compressed folder

I am trying to build a script written in Python which explore an archive (in this case a zip), and recursively gets all meta-data of files. I usually use the following command to get meta-data: (mode, ino, dev, nlink, uid, gid, size, atime, mtime,…
Labo29
  • 117
  • 3
  • 13
2
votes
1 answer

Python remove entry from zipfile

I'm currently writing an open source library for a container format, which involves modifying zip archives. Therefore I utilized pythons build-in zipfile module. Due to some limitations I decided to modify the module and ship it with my library.…
FreakyBytes
  • 151
  • 1
  • 9
2
votes
0 answers

MemoryError zipfile in memory

I'm getting MemoryError (out of memory) when zipping files in memory with Python. I'm using cStringIO.StringIO as an in memory buffer stream. Follow the code below: zip_file = cStringIO.StringIO() with zipfile.ZipFile(file=zip_file,…
2
votes
1 answer

How to take a zipfile as a File object in django?

I have a folder named 'src' of which I create a zip file named zf. I want to pass zf as a FileField object to newobj.fd. import zipfile from django.core.files import File f='s1.zip' zf = zipfile.ZipFile(f, "w") for dirname, subdirs, files in…
Sam
  • 113
  • 1
  • 1
  • 9
2
votes
0 answers

zipfile - extract method executes without error but file is not extracted

I have a very simple zipfile implementation in python which succeeds at extracting from certain zip files but fails consistently on other files. When it succeeds (obviously) the code executes and the files are extracted from the zip. When it fails…
10mjg
  • 573
  • 1
  • 6
  • 18
2
votes
1 answer

zipfile.write() file with turkish chars in filename

On my system there are many Word documents and I want to zip them using the Python module zipfile. I have found this solution to my problem, but on my system there are files which contain German umlauts and Turkish characters in their filename. I…
kiltek
  • 3,183
  • 6
  • 47
  • 70
2
votes
2 answers

Python:writing files in a folder to zipfile and compressing it

I am trying to zip and compress all the files in a folder using python. The eventual goal is to make this occur in windows task scheduler. import os import zipfile src = ("C:\Users\Blah\Desktop\Test") os.chdir=(src) path =…
vmedhe2
  • 237
  • 4
  • 19
2
votes
1 answer

Rename and extract zipfile in python

Wanted to extract .zip file one by one. Before extracting I need to rename myzip = zipfile.ZipFile(source,'r') for zib_e in myzip.namelist(): filename = os.path.basename(zib_e) if not filename: continue print…
jOSe
  • 687
  • 11
  • 22
2
votes
1 answer

Zipfile not writing data

I have tried to zip log files that I have created, but nothing is written! Code: def del_files(): '''Adapted from answer @ http://stackoverflow.com/questions/7217196/python-delete-old-files by jterrace''' dir_to_search =…
Restioson
  • 131
  • 1
  • 10
2
votes
1 answer

Python zipfile crashes gives an error for some files

I have a simple code to zip files using zipfile module. I am able to zip some files but I get FileNotFound error for the others. I have checked if this is file size error but its not. I can pack files with name like example file.py but when I have a…
MaciejPL
  • 1,017
  • 2
  • 9
  • 16
2
votes
1 answer

Reading password protected Word Documents with zipfile

I am trying to read a password protected word document on Python using zipfile. The following code works with a non-password protected document, but gives an error when used with a password protected file. try: from xml.etree.cElementTree import…
Xander
  • 593
  • 1
  • 5
  • 19
2
votes
1 answer

Python file-IO and zipfile. Trying to loop through all the files in a folder and then loop through the texts in respective file using Python

Trying to extract all the zip files and giving the same name to the folder where all the files are gonna be. Looping through all the files in the folder and then looping through the lines within those files to write on a different text file. This is…
Anjil Dhamala
  • 1,544
  • 3
  • 18
  • 37
2
votes
4 answers

Extracting a .app from a zip file in Python, using ZipFile

I'm trying to extract new revisions of Chromium.app from their snapshots, and I can download the file fine, but when it comes to extracting it, ZipFile either extracts the chrome-mac folder within as a file, says that directories don't exist, etc. I…
skylerl
  • 4,030
  • 12
  • 41
  • 60
2
votes
1 answer

Good ways to handle dynamic zipfile creation in Python

I have a reporting function on my Web Application that has been subjected to Feature Creep -- instead of providing a PDF, it must now provide a .zip file that contains a variety of documents. Generating the documents is fine. Adding documents to…
Jonathan Vanasco
  • 15,111
  • 10
  • 48
  • 72