Confused compare function :)

Anatoli Hristov tolidtm at
Thu Dec 6 19:55:09 CET 2012

> gmane.comp.python.general:
>> But basically, the code seems to run a pair of nested for-loops:
>> for SKU in database:
>>     for SKU in csv file:
>>         if the two SKUs match:
>>             compare their prices and update the database
>         OUCH...
>         I'm presuming the CSV is restarted each time the database record
> changes...
>         That would seem better reformulated as:
>         for (SKU, price) in CSV:
>                 DB.execute("update SKUtable set price = %s where SKU = %s",
>                                                 (price, SKU)    )
> --
I don't know if I get it right, but
Nope, each loop I'm getting:
for x in CSV:
1920x1080 TN Panel Speakers 2MS Black;130;9;RECTD0.41;0,41;;;;;;;;;

So x[4] is my SKU and x[5] is price and so on. Each loop looks like this.

More information about the Python-list mailing list