Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; '%s"': 0.07; 'try:': 0.07; 'valueerror:': 0.07; 'python': 0.09; '754': 0.09; 'typeerror:': 0.09; 'advance': 0.10; 'def': 0.10; '"%s': 0.16; 'comma': 0.16; 'csv': 0.16; 'found"': 0.16; 'indexerror:': 0.16; 'row': 0.16; 'subject:compare': 0.16; 'all,': 0.21; 'received:209.85.214.174': 0.21; 'pass': 0.25; 'replace': 0.27; 'message-id:@mail.gmail.com': 0.27; 'run': 0.28; "i'm": 0.29; 'function': 0.30; 'file': 0.32; 'print': 0.32; 'goes': 0.33; 'function.': 0.33; 'problem': 0.33; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'received:google.com': 0.34; 'thanks': 0.34; 'list': 0.35; 'received:209.85': 0.35; 'next': 0.35; 'except': 0.36; 'skip:u 20': 0.36; 'compare': 0.36; 'stock': 0.36; 'does': 0.37; 'received:209': 0.37; 'to:addr:python.org': 0.39; 'received:209.85.214': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'prices': 0.62; 'here': 0.65; 'total': 0.65; 'price': 0.66; 'products.': 0.74; 'mistake': 0.91; 'from.': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=03lBsHKkJEZ6O1JhI0xB9iyQAwwiEklmGTVKCCuBFL4=; b=RWhSUV3LwNgu7afCjOKk0/lfkVw6V5a1h8Vlbfao1ekY1gIVQabr7BxWmj+e3LT+Py qrSEDvl/tCGOf7b8A1OqNSQqfAr9oIq0UMXbQq6ZGm85LH5uh17rNxnCsKZET90tMUfB nGZ+wETFBmQMvHTKuKC8JDljDICIbZ/AMN2z2PF56QKeeHAE9Dr3b3FM5cOU03S/Ohg+ uj/fOmGvyWphOAJrMVzaQ9T4QWsB/KSK67nanhUvJdqR01bGGWZ2tXHGVj+gjuQ1DUpS pN7hK1SfLEsUNqtRHyRKDL3aNLRpQePPNLnR3hpcFGe8hN0oIFYzfOzV6KOa4WNNYpui 0itA== MIME-Version: 1.0 Date: Wed, 5 Dec 2012 23:50:49 +0100 Subject: Confused compare function :) From: Anatoli Hristov To: python-list@python.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 63 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1354747852 news.xs4all.nl 6881 [2001:888:2000:d::a6]:35077 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34338 Hi all, I'm confused again with a compare update function. The problem is that my function does not work at all and I don't get it where it comes from. in my DB I have total of 754 products. when I run the function is says: Total updated: 754 Total not found with in the distributor: 747 I just don't get it, can you find my mistake ? Thanks in advance def Change_price(): total = 0 tnf = 0 for row in DB: # DB is mySQL DB, logically I get out 1 SKU and I compare it with next loop isku = row["sku"] isku = isku.lower() iprice = row["price"] iprice = int(iprice) found = 0 try: for x in PRICELIST:# here is my next loop in a CSV file which is allready in a list PRICELIST try: dprice = x[6] dprice = dprice.replace(",",".") # As in the PRICELIST the prices are with commas I replace the comma as python request it dprice = float(dprice) newprice = round(dprice)*1.10 dsku = x[4] dsku = dsku.lower() stock = int(x[7]) if isku == dsku and newprice < int(iprice):# If found the coresponded SKU and the price is higher than the one in the CSV I update the price print dsku, x[6], dprice, newprice Update_SQL(newprice, isku)# goes to the SQL Update print isku, newprice if isku == dsku:# Just a check to see if it works print "Found %s" %dsku found = 1 else: found = 0 except IndexError: pass except ValueError: pass except TypeError: pass except IndexError: pass if found == 1: print "%s This is match" % isku if found == 0: print "%s Not found" % isku tnf = tnf +1 total = total +1 print "Total updated: %s" % total print"Total not found with in the distributor: %s" % tnf