python lxml loop on match get next entry

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


python lxml loop on match get next entry



I'm using LXML to query multiple XML files containing data elements on various products. This section of code is taking a list of missing product_ids and querying the XML files for the data elements for the products.



One of my core issues is that every product_id obtained through xpath is checked against every item in the list products_missing_from_postgresql, which takes forever (hours)



How do I restart the for entry in entries loop when a match is found?



Maybe this isn't the right question...if not what is the right question?


for product_number in products_missing_from_postgresql:
try:
for entry in entries:

product_id = entry.xpath('@id')[0]

if product_id != product_number:

print('************************')
print('current product: ' + product_id)
print('no match: ' + product_number)
print('************************')

else:

print('************************')
print('************************')
print('product to match: ' + product_number)
print('matched from entry: ' + product_id)
print('************************')
print('************************')



Code output:


************************
************************
product to match: B3F2H-STH
matched from entry: B3F2H-STH
************************
************************

************************
current product: B3F2H-STL
no match: B3F2H-STH
************************

************************
current product: B3F2H-004
no match: B3F2H-STH
************************









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

dnmgEJ4,It,dF,t,OPqAZP gq9B,nut7yfivQGh5I8zA18Lw2fTEVYsgKF
iI,J4TN4Skc 1jsLY0pLR,3sDrx,7,kA T6VeWyQN0Z,PNxgr1j,F6mjloghA79 7q90c LyUdoDZSRYhkdbLhFciYxYkMM

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham