BadZipfile error in xlsx2csv (https://github.com/dilshod/xlsx2csv)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • snehal dixit
    New Member
    • Apr 2013
    • 1

    BadZipfile error in xlsx2csv (https://github.com/dilshod/xlsx2csv)

    Hi,
    I am trying to convert .xlsx file to csv file using xlsx2csv methd(https://github.com/dilshod/xlsx2csv) but I am getting following error:
    Traceback (most recent call last):
    File "C:\Program Files (x86)\eclipse-SDK-4.2.1-win32\eclipse\d ropins\PyDev 2.7.1\plugins\o rg.python.pydev _2.7.1.20121009 13\pysrc\pydev_ runfiles.py", line 432, in __get_module_fr om_str
    mod = __import__(modn ame)
    File "C:\Users\nages h\workspace\mte ch_project__pha se_2\src\csvtod ic.py", line 3, in <module>
    xlsx2csv("mprod uct.xlsx", open("mproduct_ converted.csv", "w+"))
    File "C:\Users\nages h\workspace\mte ch_project__pha se_2\src\xlsxto csv.py", line 115, in xlsx2csv
    ziphandle = zipfile.ZipFile (infilepath)
    File "C:\Python27\li b\zipfile.py", line 714, in __init__
    self._GetConten ts()
    File "C:\Python27\li b\zipfile.py", line 748, in _GetContents
    self._RealGetCo ntents()
    File "C:\Python27\li b\zipfile.py", line 763, in _RealGetContent s
    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\mtec h_project__phas e_2\src\csvtodi c.py).

    Can anyone help?
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    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.

    Comment

    • bvdet
      Recognized Expert Specialist
      • Oct 2006
      • 2851

      #3
      zipfile.BadZipF ile 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:
      Code:
          kwargs = {
            'sheetid' : 0,
            'delimiter' : ',',
            'sheetdelimiter' : "--------",
            'dateformat' : None,
            'skip_empty_lines' : True
          }
          f = open("twolettercolumns.csv", 'w')
          xlsx2csv("twolettercolumns.xlsx", f, **kwargs)
          f.close()

      Comment

      Working...