[英]Merging iqy files with python
currently I extracted data from sharepoint and have .iqy files that I can open with excel.目前,我从 sharepoint 中提取了数据,并拥有可以用 excel 打开的 .iqy 文件。 There are about 30 files and I am trying to merge all the information into one .iqy file or excel file with python.
大约有 30 个文件,我正在尝试使用 python 将所有信息合并到一个 .iqy 文件或 excel 文件中。
import os, glob
import pandas as pd
files = []
for file in os.listdir("C:\\Users\\CHI86786\\Downloads"):
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)
combined.to_excel("SPmerged.iqy", header=False, index=False)
took a same approach as if I would merge excel files.采取了与合并excel文件相同的方法。 but I keep getting an error that reads
FileNotFoundError: [Errno 2] No such file or directory: 'desktop.ini'
但我不断收到一个错误,内容为
FileNotFoundError: [Errno 2] No such file or directory: 'desktop.ini'
EDIT编辑
more of the error message更多错误信息
File "C:\Users\CHI\source\repos\MergingExcel\MergingExcel\MergingExcel.py", line 8, in <module>
excels = [pd.ExcelFile(name) for name in files] #reads names in
File "C:\Users\CHI86786\source\repos\MergingExcel\MergingExcel\MergingExcel.py", line 8, in <listcomp>
excels = [pd.ExcelFile(name) for name in files] #reads names in
File "C:\Users\CHI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pandas\io\excel.py", line 394, in __init__
self.book = xlrd.open_workbook(self._io)
File "C:\Users\CHI\AppData\Local\Programs\Python\Python37-32\lib\site-packages\xlrd\__init__.py", line 116, in open_workbook
with open(filename, "rb") as f:
FileNotFoundError: [Errno 2] No such file or directory: 'desktop.ini'
Your code is trying to act on every file in C:\\Users\\CHI86786\\Downloads
, including system files like "desktop.ini".您的代码试图对
C:\\Users\\CHI86786\\Downloads
每个文件进行操作,包括“desktop.ini”等系统文件。
Instead, try restricting it to the files you're interested in using glob
:相反,尝试使用
glob
将其限制为您感兴趣的文件:
for file in glob.glob("C:\\Users\\CHI86786\\Downloads\\*.iqy")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.