标签:imp mini bsp nis index output name put code
import pandas as pd import os #文件路径注意用\\ inputfilepath = ‘C:\\Users\\Administrator\\AAA\\BBB\\‘ outputfilepath = ‘C:\\Users\\Administrator\\AAA\\‘ df_filename = ‘file_8_27-11_19.csv‘ columns_list = [‘id‘, ‘Code‘, ‘Name‘, ‘update_time‘] #先创建一个只有表头列名的空dataframe,保存为csv df = pd.DataFrame(columns = columns_list) df.to_csv(outputfilepath + df_filename) #遍历输入路径文件夹,用pandas读取后追加在目标csv文件中 for inputfile in os.listdir(inputfilepath): df = pd.read_csv(inputfilepath+inputfile) df.to_csv(outputfilepath + df_filename, mode=‘a‘, index=True,header = False) #查看合并后的表格 pd.read_csv(outputfilepath + df_filename)
标签:imp mini bsp nis index output name put code
原文地址:https://www.cnblogs.com/levylaw/p/12316302.html