使用python编程实现多个csv文件数据的合并和输出

具体代码

import pandas as pd
import os

df01 = pd.read_csv("D:\\12140\\Desktops\\111\\t11.csv", encoding='utf-8', dtype='str')

df02 = pd.read_csv("D:\\12140\\Desktops\\111\\t12.csv", encoding='utf-8', dtype='str')

df03 = pd.read_csv("D:\\12140\\Desktops\\111\\t13.csv", encoding='utf-8', dtype='str')

df04 = pd.read_csv("D:\\12140\\Desktops\\111\\t14.csv", encoding='utf-8', dtype='str')

df_pri12 = pd.merge(df01, df02, on='成果名称', how='outer')

df_pri123 = pd.merge(df_pri12, df03, on="成果名称", how='outer')

df_pri1234 = pd.merge(df_pri123, df04, on="成果名称", how='outer')

df_pri1234.to_csv('D:\\12140\\Desktops\\111\\222\\test001.csv', header=True, index=False)

效果展示

posted @ 2024-03-06 13:55  yesyes1  阅读(114)  评论(0编辑  收藏  举报