zipfile

Web2Py - Upload a file and read the content as Zip file

可紊 提交于 2019-12-10 00:45:42
问题 I am trying to upload a zip file from Web2Py form and then read the contents: form = FORM(TABLE( TR(TD('Upload File:', INPUT(_type='file', _name='myfile', id='myfile', requires=IS_NOT_EMPTY()))), TR(TD(INPUT(_type='submit',_value='Submit'))) )) if form.accepts(request.vars): data=StringIO.StringIO(request.vars.myfile) import zipfile zfile=zipfile.Zipfile(data) For some reason this code does work and complains of file not being a zip file although the uploaded file is a zip file. I am new to

Python - how to convert unicode filename to CP437?

▼魔方 西西 提交于 2019-12-10 00:12:51
问题 I have a file that has a Unicode name, say 'קובץ.txt' . I want to pack him, and I'm using python's zipfile. I can zip the files and open them later on with a problem except that file names are messed up when using windows 7 file explorer to view the files (7zip works great). According to the docs, this is a common problem, and there are instructions on how to deal with that: From ZipFile.write Note There is no official file name encoding for ZIP files. If you have unicode file names, you must

Compression fails when using ionic zip

纵然是瞬间 提交于 2019-12-09 15:55:50
问题 I am using the latest version of ionic zip version 1.9.1.8.I have set the property of ionic zip ParallelDeflateThreshold = 0 . The zipping mechanism was working perfectly for the past two months.Suddenly this stopped working.The zipping thread just hangs,ionic zip just created the tmp file and failed to create the zip file. I could easily reproduce this issue even with small file size. My analysis for this issue is as follows The issue was with the latest version of ionic zip, in this case

Python - Extracting files from a large (6GB+) zip file

眉间皱痕 提交于 2019-12-09 06:53:27
问题 I have a Python script where I need to extract the contents of a ZIP file. However, the zip file is over 6GB in size. There is a lot of information about zlib and zipfile modules, however, I can't find a single approach that works in my case. I have the code: with zipfile.ZipFile(fname, "r") as z: try: log.info("Extracting %s " %fname) head, tail = os.path.split(fname) z.extractall(folder + "/" + tail) except zipfile.BadZipfile: log.error("Bad Zip file") except zipfile.LargeZipFile: log.error

How to Zip files using JavaScript?

可紊 提交于 2019-12-09 05:13:54
问题 Is there a way to zip files using JavaScript?? For an example, like in Yahoo mail, when you chose to download all the attachments from an email, it gets zipped and downloaded in a single zip file. Is JavaScript capable of doing that? If so, please provide a coding example. I found this library called jszip to do the task but it has known and unresolved issues. How do I solve the problem? 回答1: JSZip has been updated over the years. Now you can find it on its GitHub repo It can be used together

Extract files with invalid characters in filename with Python

给你一囗甜甜゛ 提交于 2019-12-09 00:52:11
问题 I use python's zipfile module to extract a .zip archive (Let's take this file at http://img.dafont.com/dl/?f=akvaleir for example.) f = zipfile.ZipFile('akvaleir.zip', 'r') for fileinfo in f.infolist(): print fileinfo.filename f.extract(fileinfo, '.') Its output: Akval�ir_Normal_v2007.ttf Akval�ir, La police - The Font - Fr - En.pdf Both files are unaccessable after extraction because there are invalid encoded characters in their filenames. The problem is zipfile module doesn't have an option

How to read data from nested zip files in Java without using temporary files?

感情迁移 提交于 2019-12-08 09:12:38
问题 I am trying to to extract files out of a nested zip archive and process them in memory. What this question is not about: How to read a zip file in Java: NO, the question is how to read a zip file within a zip file within a zip and so on and so forth (as in nested zip files). Write temporary results on disk: NO, I'm asking about doing it all in memory. I found many answers using the not-so-efficient technique of writing results temporarily to disk, but that's not what I want to do. Example:

Python cant handle exceptions from zipfile.BadZipFile

微笑、不失礼 提交于 2019-12-08 08:14:39
问题 Need to handle if a zip file is corrupt, so it just pass this file and can go on to the next. In the code example underneath Im trying to catch the exception, so I can pass it. But my script is failing when the zipfile is corrupt*, and give me the "normal" traceback errors* istead of printing "my error", but is running ok if the zipfile is ok. This i a minimalistic example of the code I'm dealing with. path = "path to zipfile" from zipfile import ZipFile with ZipFile(path) as zf: try: print

How to find any file within a Directory of a Zipfile

佐手、 提交于 2019-12-08 05:38:46
问题 I'm setting up a function where I collect a list of apk files, then inside a For-loop, I declare a ZipFile intense to check the ABI Directories under the lib folder, by checking if any file ends with ".so". The only option I can solution I can think of is to use regex String expressions I've made several regex expression attempts with \b, [A-Za-z-0-9]*, but I keep getting NullPointerException. I researched solutions for using regex with File names, but not really cases for ZipFile and

How to check if zip file is split across multiple archives using python's zipfile lib?

我的未来我决定 提交于 2019-12-08 02:13:46
问题 According to the zip file standard: http://www.pkware.com/documents/casestudies/APPNOTE.TXT it also supports splitting a zip file across multiple files: Spanned/Split archives created using PKZIP for Windows (V2.50 or greater), PKZIP Command Line (V2.50 or greater), or PKZIP Explorer will include a special spanning signature as the first 4 bytes of the first segment of the archive. This signature (0x08074b50) will be followed immediately by the local header signature for the first file in the