0

I have multiple .iqy files I want to be able to add them to a database I tried the below codes:

import os, glob
import pandas as pd

files = []
for file in glob.glob("D:\Forms\Forms_Link\*.iqy"):
files.append(file)

excels = [pd.ExcelFile(name) for name in files]
frames = [x.parse(x.sheet_names[0], header=None, index_col=None) for x in excels]

frames[1:] = [df[1:] for df in frames[1:]]

combined = pd.concat(frames)

Howevver, I'm receiving an error that

** ValueError Traceback (most recent call last) in ----> 1 excels = [pd.ExcelFile(name) for name in files] 2 frames = [x.parse(x.sheet_names[0], header=None, index_col=None) for x in excels] 3 4 frames[1:] = [df[1:] for df in frames[1:]] 5

in (.0) ----> 1 excels = [pd.ExcelFile(name) for name in files] 2 frames = [x.parse(x.sheet_names[0], header=None, index_col=None) for x in excels] 3 4 frames[1:] = [df[1:] for df in frames[1:]] 5

~\Anaconda3\lib\site-packages\pandas\io\excel_base.py in init(self, path_or_buffer, engine, storage_options) 1069 ext = "xls" 1070 else: -> 1071 ext = inspect_excel_format( 1072 content=path_or_buffer, storage_options=storage_options 1073 )

~\Anaconda3\lib\site-packages\pandas\io\excel_base.py in inspect_excel_format(path, content, storage_options) 963 return "xls" 964 elif not peek.startswith(ZIP_SIGNATURE): --> 965 raise ValueError("File is not a recognized excel file") 966 967 # ZipFile typing is overly-strict

ValueError: File is not a recognized excel file **

  • `.iqy` files are queries for sharepoint, they don't contain any data on their own, neither they have an excel format. Therefore error `file is not a recognized excel file` is quite logical. It should be possible to load xml/excel files from sharepoint using those .iqy files and parse them afterwards, see e.g. this answer: https://stackoverflow.com/a/63110216/2792888 – Alexandra Dudkina Jan 23 '22 at 08:15

0 Answers0