By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,822 Members | 1,048 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,822 IT Pros & Developers. It's quick & easy.

BadZipfile error in xlsx2csv (

P: 1
I am trying to convert .xlsx file to csv file using xlsx2csv methd( but I am getting following error:
Traceback (most recent call last):
File "C:\Program Files (x86)\eclipse-SDK-4.2.1-win32\eclipse\dropins\PyDev 2.7.1\plugins\org.python.pydev_2.7.1.2012100913\py src\", line 432, in __get_module_from_str
mod = __import__(modname)
File "C:\Users\nagesh\workspace\mtech_project__phase_2\ src\", line 3, in <module>
xlsx2csv("mproduct.xlsx", open("mproduct_converted.csv", "w+"))
File "C:\Users\nagesh\workspace\mtech_project__phase_2\ src\", line 115, in xlsx2csv
ziphandle = zipfile.ZipFile(infilepath)
File "C:\Python27\lib\", line 714, in __init__
File "C:\Python27\lib\", line 748, in _GetContents
File "C:\Python27\lib\", line 763, in _RealGetContents
raise BadZipfile, "File is not a zip file"
BadZipfile: File is not a zip file
ERROR: Module: csvtodic could not be imported (file: C:\Users\nagesh\workspace\mtech_project__phase_2\s rc\

Can anyone help?
Apr 11 '13 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 10K+
P: 12,441
I don't really know python but it sounds like you're trying to use a zip function and the file you're referencing for that function is not a zip file.

Of course, there's not much we can help you with if you don't post your code.
Apr 11 '13 #2

Expert Mod 2.5K+
P: 2,851
zipfile.BadZipFile is the exception raised by the zipfile module. I don't know enough about xlsx2csv to know why. The actual error may be masked in some way. The following does work:
Expand|Select|Wrap|Line Numbers
  1.     kwargs = {
  2.       'sheetid' : 0,
  3.       'delimiter' : ',',
  4.       'sheetdelimiter' : "--------",
  5.       'dateformat' : None,
  6.       'skip_empty_lines' : True
  7.     }
  8.     f = open("twolettercolumns.csv", 'w')
  9.     xlsx2csv("twolettercolumns.xlsx", f, **kwargs)
  10.     f.close()
Apr 11 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.