Confused compare function :)

Anatoli Hristov tolidtm at gmail.com
Thu Dec 6 12:31:26 EST 2012


>> Here is the product in the CSV:
>> MONIIE2407HDS-B1;MON;II;E2407HDS-B1;E2407HDS-B1;IIYAMA LCD 24" Wide
>> 1920x1080TN Speakers 2ms Black DVI HDMI;133;20;RECTD0.41;0,41;;;;;;;;;

This one is still not found and it is in the CSV file - I just don't
get it why !

>>                      if len(db_sku) != 0 and match:
>>                          TotalSKUFound +=1
> TotalSKUFound is incremented if it finds a match.
>
> Can "db_sku in csv_sku" be true multiple times for a given value of
> db_sku? (See above.) Is it possible that TotalSKUFound is incremented
> multiple times for some values of csv_sku?

Most of the SKU's are not doubled in the CSV, but what I will do is to
create new function to compare each SKU so after it founds the SKU in
the file it will return right away to the DB loop.

>>                          if csv_new_price < db_price and csv_stock > 0:
>>                              print db_sku, csv_price, db_price,
>> csv_new_price
>>                              Update_SQL(csv_new_price, db_sku)
>>                              TotalUpdated += 1
>>                              found = True

> It sets found to True if it updated.
>>                  except IndexError: # I have a lot of index error in the
>> CSV (empty fields) and the loop gives "index error" I  don't care about them
>>                      pass
>>                  except ValueError:
>>                      pass
>>                  except TypeError:
>>                      pass
>
>
> Even after finding a match (and possibly updating), it continues
> iterating though pricelist.

Yes it will change after I create the new func.as I assume.

>>          except IndexError:
>
>
         if not found: WriteLog(db_sku, db_sku,)
>
>
> Calling it 'found' is misleading, because it's True only if it updated.
> If it found a match but didn't update, 'found' will still be False.
> Using a loop within a loop like this could be the cause of your
> problem. It's certainly not the most efficient way of doing it.

I will keep you posted THANK YOU



More information about the Python-list mailing list