python

您所在的位置:网站首页 pycharm遍历 python

python

2023-03-14 22:20| 来源: 网络整理| 查看: 265

如何使用python合并多个excel文件

Eroeg: 大神,我在使用的你的代码,添加了一个判断文件名的语句,运行没问题,但是加入循环后,提示“zipfile.BadZipFile: File is not a zip file” [code=python]def append(path,stationname): filename_excel = [] frames = [] for root, dirs, files in os.walk(path): for file in files: if file[:5] == stationname: file_with_path = os.path.join(root, file) filename_excel.append(file_with_path) df = pd.read_excel(file_with_path, engine='openpyxl', skiprows=1) frames.append(df) df = pd.concat(frames, axis=0) df.dropna(axis=0, how='any', inplace=True)[/code] [code=python] if __name__ == '__main__': path1 = r'C:\Users\……\……\data' stationnames = ['Q8733', 'Q8806', 'Q8604', 'Q8813'……] for i in stationnames: df1 = append(path1, i) [/code]



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3