|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import pandas as pd
import os
data_list = []
for fname in os.listdir("."):
if fname.startswith("收货查询0") and fname.endswith(".xls"):
data_list.append(pd.read_excel(fname))
data_all = pd.concat(data_list)
data_all.to_excel("合并.xls",index=False)
如上代码,为什么我在执行的时候提示错误,我初步感觉是因为我的模块有问题,好像无法识别 .xls,但是不知道对不对,也不知道怎么修正,求帮忙,具体错误如下:
D:\Program Files\PYTHON\lib\site-packages\openpyxl\styles\stylesheet.py:226: UserWarning: Workbook contains no default style, apply openpyxl's default
warn("Workbook contains no default style, apply openpyxl's default")
D:/wangxuewen19/Downloads/合并/批量合并Excel.py:12: FutureWarning: As the xlwt package is no longer maintained, the xlwt engine will be removed in a future version of pandas. This is the only engine in pandas that supports writing in the xls format. Install openpyxl and write to an xlsx file instead. You can set the option io.excel.xls.writer to 'xlwt' to silence this warning. While this option is deprecated and will also raise a warning, it can be globally set and the warning suppressed.
data_all.to_excel("合并.xls",index=False)
Traceback (most recent call last):
File "D:/wangxuewen19/Downloads/合并/批量合并Excel.py", line 12, in <module>
data_all.to_excel("合并.xls",index=False)
File "D:\Program Files\PYTHON\lib\site-packages\pandas\core\generic.py", line 2345, in to_excel
formatter.write(
File "D:\Program Files\PYTHON\lib\site-packages\pandas\io\formats\excel.py", line 888, in write
writer = ExcelWriter( # type: ignore[abstract]
File "D:\Program Files\PYTHON\lib\site-packages\pandas\io\excel\_xlwt.py", line 39, in __init__
import xlwt
ModuleNotFoundError: No module named 'xlwt' |
|