Title: Error message trying to merge 2 excels into one
Tags: python,pandas

Question: The code below is supposed to merge 2 excels into one, but for some reason is it causing an error:
import pandas as pd

JL_MP_PE_07A = pd.read_excel(r'D:\Maintenance\Bloc 6\PROJECT KPI\Performance\JL-MP-PE-07A.xlsx', skiprows=22, engine='openpyxl')
JL_MP_PE_07B = pd.read_excel(r'D:\Maintenance\Bloc 6\PROJECT KPI\Performance\JL-MP-PE-07B.xlsx', skiprows=23, engine= 'openpyxl')

merged_df = pd.concat([JL_MP_PE_07A, JL_MP_PE_07B])

merged_df.to_excel('D:\Maintenance\Bloc 6\PROJECT KPI\Performance\merged_OT_file.xlsx', index=False)


I run the program and I get the following error, I tried ziping each file and I added 'r' at the start of each path. Still a problem
File "d:\Maintenance\Bloc 6\PROJECT KPI\Performance\Source code\Performance_Excel merger.py", line 5, in <module>
    JL_MP_PE_07B = pd.read_excel(r'D:\Maintenance\Bloc 6\PROJECT KPI\Performance\JL-MP-PE-07B.xlsx', skiprows=23, engine= 'openpyxl')    
   
  File "C:\Users\seljoukia\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\excel\_base.py", line 478, in read_excel  
    io = ExcelFile(io, storage_options=storage_options, engine=engine)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\seljoukia\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\excel\_base.py", line 1513, in __init__   
    self._reader = self._engines[engine](self._io, storage_options=storage_options)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\seljoukia\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\excel\_openpyxl.py", line 549, in __init__
    super().__init__(filepath_or_buffer, storage_options=storage_options)
  File "C:\Users\seljoukia\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\excel\_base.py", line 540, in __init__
    self.book = self.load_workbook(self.handles.handle)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\seljoukia\AppData\Local\Programs\Python\Python311\Lib\site-packages\pandas\io\excel\_openpyxl.py", line 560, in load_workbook
    return load_workbook(
           ^^^^^^^^^^^^^^
  File "C:\Users\seljoukia\AppData\Local\Programs\Python\Python311\Lib\site-packages\openpyxl\reader\excel.py", line 344, in load_workbook
    reader = ExcelReader(filename, read_only, keep_vba,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\seljoukia\AppData\Local\Programs\Python\Python311\Lib\site-packages\openpyxl\reader\excel.py", line 123, in __init__
    self.archive = _validate_archive(fn)
                   ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\seljoukia\AppData\Local\Programs\Python\Python311\Lib\site-packages\openpyxl\reader\excel.py", line 95, in _validate_archive
    archive = ZipFile(filename, 'r')
              ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\seljoukia\AppData\Local\Programs\Python\Python311\Lib\zipfile.py", line 1301, in __init__
    self._RealGetContents()
  File "C:\Users\seljoukia\AppData\Local\Programs\Python\Python311\Lib\zipfile.py", line 1368, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file

Answer: Make sure to avoid the engine or change to xlrd
It may solve your error