import pandas as pd from sqlalchemy import create_engine path="C://Users//Administrator//Desktop/指标//" data=pd.DataFrame() flile=os.listdir(path) list_len=len(flile) for i in range(list_len): data_exce = pd.read_csv(path + flile[i]) data = data.append(data_exce) data.columns=['ID',"unname",'Country','Countrycode', 'Year', 'Is_Leaf', 'Index_Id', 'Tm_Index_Value', 'Mc_Index_Value'] del data['unname'] print(data) engine=create_engine("mysql+pymysql://root:136382@localhost:3306/wutanghua?charset=utf8") data.to_sql( 'equ', con=engine, if_exists='append',index=False)
原创文章,作者:wure,如若转载,请注明出处:https://blog.ytso.com/277333.html