Confused compare function :)

Anatoli Hristov tolidtm at gmail.com
Thu Dec 6 13:55:09 EST 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:
MONIIE2409HDS-B1;MON;II;E2409HDS-B1;E2409HDS-B1;IIYAMA LCD 24" Wide
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