在這里,我試圖將一個表與具有數(shù)百萬個記錄的2個表進(jìn)行比較,所以我想分別比較dem并在主表“ tabl”名稱狀態(tài)中創(chuàng)建一個單獨(dú)的列,以便我可以自己更新步驟:在主表中的電子郵件名稱“ status”旁邊創(chuàng)建一個新列步驟2:必須在與tab1,tab2表進(jìn)行比較時更新該列l(wèi)ist_of_tables=['tab1','tab2'] for tab in list_of_tables: cursor.execute("select main.*,if({}.email is not null ,'MATCH','NONMATCH') stataus from main left join {} on main.email={}.email".format(tab,tab,tab)) data_2 = cursor.fetchall() print data_2 data3=list(data_2) data_3=pd.DataFrame(data3) upload(ftp,data_3,FILEPATH)def upload(ftp,data_3,FILEPATH): data_4=data_3.to_csv(Out_file,index=False,header=None)main:emailabc@gamil.comxyz@email.comijk@gmail.comghi@gmail.compqr@gmail.comyup@gmail.comtab1:emailijk@gmail.comyup@gmail.comtab2:emailxyz@email.compqr@gmail.com要求的結(jié)果email validabc@gamil.com non-matchxyz@email.com matchijk@gmail.com matchghi@gmail.com non-matchpqr@gmail.com matchyup@gmail.com matchbut getting like dis:abc@gamil.com non-matchxyz@email.com non-matchijk@gmail.com matchghi@gmail.com non-matchpqr@gmail.com non-matchyup@gmail.com matchabc@gamil.com nonmatchxyz@email.com matchijk@gmail.com nonmatchghi@gmail.com nonmatchpqr@gmail.com nonmatchyup@gmail.com nonmatch
添加回答
舉報
0/150
提交
取消