python - Python使用密码将多个Excel合二为一
问题描述
当前的python代码没有将数据从多个excel复制到一个主excel,没有错误??有谁知道我做错了什么?
工作表名称 Sheet1
还需要合并我认为我已经完成的密码输入。
import os
import pandas as pd
import openpyxl
cwd = os.path.abspath(r'C:/Users/eldri/OneDrive/Desktop/test/')
cwd = cwd.replace("'\'", "'/'")
files = os.listdir(cwd)
shtname = ('Sheet1')
print (cwd)
print (files)
xltot = pd.DataFrame()
for file in files:
if file.endswith('*.xlsx'):
excel_file.security.workbookPassword = 'password'
excel_file = pd.ExcelFile(file)
sheets = excel_file.shtname
for sheet in sheets:
xl = excel_file.parse(shtname)
xltot = xltot.append(xl)
xltot.to_excel('compiled_xl.xlsx', 'Compiled Excels')
print("Done")
print shows:
C:\Users\eldri\OneDrive\Desktop\test
['cgnbcgnn.xlsx', 'cgncgn.xlsx', 'cgncgnc.xlsx', 'cgng.xlsx', 'fdgfg.xlsx', 'gcncgn.xlsx', 'gcngn.xlsx', 'nfvn.xlsx']
任何帮助都会非常感谢
解决方案
推荐阅读
- reflection - Python 3.7:检测从类中访问的属性名称
- excel - 在 Excel 中的 2 个值之间以设定的间隔减去
- linux - 获取未安装 /proc 的执行路径
- python - 使用 python 的请求库无法登录网站
- c# - 计算 LookAt 而不应用它
- python - 使用 savedmodel simple_save 和 tensorflow keras 对输入进行预处理
- html - 页面中有多个滑动菜单
- ios - 与具有多个子 ViewControllers 的 ViewController 交互
- java - 如何将我的程序重置为今天(Java)
- maven - 如何停止输出“[警告]配置选项'appendAssemblyId'设置为false。”的maven?