1

I installed "Spyder" to try to parse an excel file using openpyxl.

First, I wrote a simple python code to read an excel file and print shell contents.

from openpyxl import load_workbook
testExcel=load_workbook('test.xlsx')
sheet1 = testExcel['Sheet1']
regs = []
for i in sheet1.rows:
    name = i[0].value
    minval = i[1].value
    maxval = i[2].value
    reg = (name, minval, maxval)
    regs.append(reg)
print(regs)

Then This code runs well using "IPython console".

But This code hasn't run when I tried to same way using "Anaconda prompt" instead of "IPython console".

Error message is like below.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\ProgramData\Anaconda3\lib\site-packages\openpyxl\reader\excel.py", line 174, in load_workbook
    archive = _validate_archive(filename)
  File "D:\ProgramData\Anaconda3\lib\site-packages\openpyxl\reader\excel.py", line 124, in _validate_archive
    archive = ZipFile(f, 'r', ZIP_DEFLATED)
  File "D:\ProgramData\Anaconda3\lib\zipfile.py", line 1108, in __init__
    self._RealGetContents()
  File "D:\ProgramData\Anaconda3\lib\zipfile.py", line 1175, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file

So I think that there are differences of operation between "Anaconda prompt" and "IPython console".

Please let me know about that.

Thanks in advance.

0 Answers0