473,394 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Error from zipfile

Dear Users,

I'm having a problem when trying to move script from Linux to Windows.
A zipfile opperation is failing with the message:

"BadZipFile: File is not a zip file"

I have a simple scripts that reads a zip file in the same way as any
other file into a string, then sends it across to a network where it
is saved as perusual into a file, then read in and processed by
zipfile. I've tried adding the flag to allow 64 bit and even using
uncompressed zip files. Niether fixes the problem.

The zip file and contents were created on linux. To be certain that
was not the issue I have emptied the zip file, created a new one,
opend all the files in wordpad and saved them, then put the contents
into the new file. Still no joy.

Any help would be greatly appreciated. On linux I'm running python 2.5
and on windows it is 2.4.

Thanks,

Wesley Brooks.
Jul 1 '08 #1
2 1280
On Tue, 01 Jul 2008 16:38:23 +0100, Wesley Brooks wrote:
Dear Users,

I'm having a problem when trying to move script from Linux to Windows.
A zipfile opperation is failing with the message:

"BadZipFile: File is not a zip file"

I have a simple scripts that reads a zip file in the same way as any
other file into a string, then sends it across to a network where it
is saved as perusual into a file, […]
Are you sure you read and save the file in binary mode, especially on
windows!?

Ciao,
Marc 'BlackJack' Rintsch
Jul 1 '08 #2
On Jul 2, 1:38 am, "Wesley Brooks" <wesbro...@gmail.comwrote:
Dear Users,

I'm having a problem when trying to move script from Linux to Windows.
A zipfile opperation is failing with the message:

"BadZipFile: File is not a zip file"

I have a simple scripts that reads a zip file in the same way as any
other file into a string, then sends it across to a network where it
is saved as perusual into a file, then read in and processed by
zipfile.
If "saved as per usual" means something like open('foo.zip',
'w').write(the_string) then this is highly likely to be your
problem. Use 'wb'. Get into the habit of using the 'b' flag on
binary files in your scripts (whether reading or writing) and they'll
be much more portable.

Something to check: on the Linux side, do
wc -l foo.zip
(that option's 'L'.lower()) to get the number of pseudo-lines in your
zip file, and compare the sizes of the file on Linux and Windows. What
do you see?

HTH,
John
Jul 1 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tung Wai Yip | last post by:
Can I add empty directory using zipfile? When I try to add a directory it complains that it is not a file. tung
1
by: LC | last post by:
Hi, I'm having a problem using the zipfile module in Windows 2000 sp4. When I use it to zip a small file it works fine, but large file doesnt. Here's the error msg i get......
19
by: Gerson Kurz | last post by:
AAAAAAAARG I hate the way python handles unicode. Here is a nice problem for y'all to enjoy: say you have a variable thats unicode directory = u"c:\temp" Its unicode not because you want it...
0
by: Ian Cook | last post by:
Hi, I'm new to python so please excuse me if this is a 'dumb' question. I want to use the ZipFile module to UPDATE, rather than append, or create a new zip file. Does anyone know how this can...
1
by: Waitman Gobble | last post by:
Hello, I am new to Python. I am having trouble with zipfile.py. On a Linux machine with python 2.4.2 I have trouble opening a zipfile. Python is complaining about the bit where it does a...
5
by: Waguy | last post by:
Hi all, I am new to python and want to create a process to unzip large numbers of zip files I get from a SOAP application. The files all have a ZIP extention and can be unzipped using WinZip. ...
11
by: Hari Sekhon | last post by:
I do import zipfile zip=zipfile.ZipFile('d:\somepath\cdimage.zip') zip.namelist() then either of the two: A) file('someimage.iso','w').write(zip.read('someimage.iso'))
5
by: OriginalBrownster | last post by:
This will probably sound like a very dumb question. I am trying to zip some files within a directory. I want to zip all the files within a directory called "temp" and have the zip archive...
8
by: =?utf-8?B?5Lq66KiA6JC95pel5piv5aSp5rav77yM5pyb5p6B | last post by:
I made a C/S network program, the client receive the zip file from the server, and read the data into a variable. how could I process the zipfile directly without saving it into file. In the...
3
by: towers | last post by:
Hi I'm probably doing something stupid but I've run into a problem whereby I'm trying to add a csv file to a zip archive - see example code below. The csv just has several rows with carriage...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.