import pandas as pd

a = open('../1_xlsx_to_csv/一般情况.csv',encoding = "utf-8")
table1 = pd.read_csv(a)
b = open('../1_xlsx_to_csv/血常规.csv',encoding = "utf-8")
table2 = pd.read_csv(b)
c = open('../1_xlsx_to_csv/生化.csv',encoding = "utf-8")
table3 = pd.read_csv(c)
d = open('../1_xlsx_to_csv/血气.csv',encoding = "utf-8")
table4 = pd.read_csv(d)
e = open('../1_xlsx_to_csv/凝血.csv',encoding = "utf-8")
table5 = pd.read_csv(e)
f = open('../1_xlsx_to_csv/术中情况.csv',encoding = "utf-8")
table6 = pd.read_csv(f)
g = open('../1_xlsx_to_csv/术中化验.csv',encoding = "utf-8")
table7 = pd.read_csv(g)
h = open('../1_xlsx_to_csv/术后输血情况.csv',encoding = "utf-8")
table8 = pd.read_csv(h)
i = open('../1_xlsx_to_csv/总体转归.csv',encoding = "utf-8")
table9 = pd.read_csv(i)
j = open('../1_xlsx_to_csv/出院前术后转归.csv',encoding = "utf-8")
table10 = pd.read_csv(j)

print('———————  合并12  ————————')
new = pd.merge(table1,table2,on=['姓名','序列号','病案号','ID号'], how='left')
print(len(table1.columns))
print(len(table2.columns))
print(len(new.columns))
print(len(new))
print('———————  合并3  ————————')
new = pd.merge(new,table3,on=['姓名','序列号','病案号','ID号'], how='left')
print(len(table3.columns))
print(len(new.columns))
print(len(new))
print('———————  合并4  ————————')
new = pd.merge(new,table4,on=['姓名','序列号'], how='left')
print(len(table4.columns))
print(len(new.columns))
print(len(new))
print('———————  合并5  ————————')
new = pd.merge(new,table5,on=['姓名','序列号','病案号','ID号'], how='left')
print(len(table5.columns))
print(len(new.columns))
print(len(new))
print('———————  合并6  ————————')
new = pd.merge(new,table6,on=['姓名','序列号','病案号','ID号'], how='left')
print(len(table6.columns))
print(len(new.columns))
print(len(new))
print('———————  合并7  ————————')
new = pd.merge(new,table7,on=['姓名','序列号','病案号','ID号'], how='left')
print(len(table7.columns))
print(len(new.columns))
print(len(new))
print('———————  合并8  ————————')
new = pd.merge(new,table8,on=['姓名','序列号','病案号','ID号'], how='left')
print(len(table8.columns))
print(len(new.columns))
print(len(new))
print('———————  合并9  ————————')
new = pd.merge(new,table9,on=['姓名','序列号','病案号','ID号'], how='left')
print(len(table9.columns))
print(len(new.columns))
print(len(new))
print('———————  合并10  ————————')
new = pd.merge(new,table10,on=['姓名','序列号','病案号','ID号'], how='left')
print(len(table10.columns))
print(len(new.columns))
print(len(new))

new.to_csv('./all_data.csv'.format(), sep=',', index=False)



