I got a problem when i tried to compare two databases that i read using python. The problem is to write proper for cycle. Databases are read using:
output_po = psql.read_frame(sql_po, conn) output_stock = psql.read_frame(sql_stock, conn)
SQL_PO records: PO PN
FTP1 1111
FTP2 2222
SQL_STOCK records PN WHS NAME 1111 VLN A 1111 VLN B 1111 ZRS A 2222 DLN Q
So the result i want to get is to get all SQL_STOCK info based on SQL_PO info where Whs == 'VLN'. Result: PO PN WHS NAME FTP1 1111 VLN A FTP1 1111 VLN B
I have tried using:
for index, row in sql_po.iterrows():
if sql_stock[sql_stock['PN']==row['PN']].empty:
send_email = 'F'
else:
if (sql_stock[sql_stock['Whs'] =='VLN'].any ):
send_email = 'T'
But it gives all 3 records for PN 1111 from sql_stock as for 1111 there are 2 with vln and 1 with zrs whs. COuld you guys help me solve that problem to write cycle for in another cycle for?
Aucun commentaire:
Enregistrer un commentaire