遍历文件夹下的csv,把数据读进一张表
import pandas as pd import os if __name__ == '__main__': Path = 'c:\checklog' dfs = [] for dir_path, dir_names, file_names in os.walk(Path): for f in file_names: if f.find('cpu_mem.csv') != -1: full_path = os.path.join(dir_path, f) print(full_path) if os.path.getsize(full_path): dfs.append(pd.read_csv(full_path, header=None)) df = pd.concat(dfs, sort=False) df.to_excel('c:\checklog\out.xlsx')