Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #34419

Re: Confused compare function :)

Path csiph.com!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!newsfeed101.telia.com!starscream.dk.telia.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <tolidtm@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.049
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'nested': 0.07; '%s",': 0.09; 'restarted': 0.09; 'cc:addr:python-list': 0.10; 'csv': 0.16; 'lcd': 0.16; 'match:': 0.16; 'subject:compare': 0.16; 'received:209.85.214.174': 0.21; 'file:': 0.22; 'cc:2**0': 0.23; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'looks': 0.26; 'skip:b 30': 0.27; 'message-id:@mail.gmail.com': 0.27; 'run': 0.28; 'record': 0.28; 'this.': 0.29; "i'm": 0.29; 'speakers': 0.30; 'code': 0.31; 'received:google.com': 0.34; 'received:209.85': 0.35; 'but': 0.36; 'compare': 0.36; 'two': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'received:209.85.214': 0.39; 'where': 0.40; 'header:Received:5': 0.40; 'wide': 0.62; 'prices': 0.62; 'skip:m 50': 0.65; 'price': 0.66; 'panel': 0.71; 'as:': 0.75; 'basically,': 0.84; 'database:': 0.84; 'x[5]': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ZOf1/fuXKOo0tpEfiR4aQKA9LPfarvl5zWAG3C5oFmE=; b=UGKWnQayPb0BYCrM4mxrwHc8NX2rX320decAF48MtmAu0LM0u7HxZvPcYbePGCKkgL zsNJ/kFWQHM4c5B19ltZOwJx+v9iuvMRTVsOB0llG0svjgQXxk29ZDCzugySLpiwDhfE uzcBBlivH3wSKv9hd26oVF8BHjq/lXTJNfkkOiEm820SosJ2GODcnzPxE/TzdumMh+w4 zZBs0B3vl6zdzewXs9fvThWVwQ5Q1ylJuFm3SghfPyGZDHA7Kx9tHeFly9fmiILMUc9j BeGxTKLxmgGy6Z+ThawIiZJA0tRAvRT0ZEb2G6F/r24RKUXCRLguPY8uYgEUvCuqGzh2 La9Q==
MIME-Version 1.0
In-Reply-To <efp1c8dqeda0a7v0mlmpt00n161com0rhm@invalid.netcom.com>
References <CAKhY55PXaMkdnW7qMb-5ConHMcz05Gnkqw4wvyoprBFBd5UFFw@mail.gmail.com> <mailman.538.1354753193.29569.python-list@python.org> <50bfe9d8$0$29994$c3e8da3$5496439d@news.astraweb.com> <efp1c8dqeda0a7v0mlmpt00n161com0rhm@invalid.netcom.com>
Date Thu, 6 Dec 2012 19:55:09 +0100
Subject Re: Confused compare function :)
From Anatoli Hristov <tolidtm@gmail.com>
To Dennis Lee Bieber <wlfraed@ix.netcom.com>
Content-Type text/plain; charset=UTF-8
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.583.1354820111.29569.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1354820111 news.xs4all.nl 6854 [2001:888:2000:d::a6]:38310
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:34419

Show key headers only | View raw


> 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.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Confused compare function :) Bruno Dupuis <python.ml.bruno.dupuis@lisael.org> - 2012-12-06 01:19 +0100
  Re: Confused compare function :) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-06 00:42 +0000
    Re: Confused compare function :) Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-12-06 13:41 -0500
    Re: Confused compare function :) Anatoli Hristov <tolidtm@gmail.com> - 2012-12-06 19:55 +0100
  Re: Confused compare function :) Rotwang <sg552@hotmail.co.uk> - 2012-12-06 03:22 +0000
    Re: Confused compare function :) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-06 04:32 +0000
      Re: Confused compare function :) Bruno Dupuis <python.ml.bruno.dupuis@lisael.org> - 2012-12-06 09:49 +0100
        Re: Confused compare function :) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-06 11:47 +0000
          Re: Confused compare function :) peter <pjmakey2@gmail.com> - 2012-12-06 08:55 -0300
            Re: Confused compare function :) Hans Mulder <hansmu@xs4all.nl> - 2012-12-06 14:32 +0100
              Re: Confused compare function :) Chris Angelico <rosuav@gmail.com> - 2012-12-07 00:47 +1100
          Re: Confused compare function :) Chris Angelico <rosuav@gmail.com> - 2012-12-06 23:14 +1100
            Re: Confused compare function :) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-07 22:16 +0000
              Re: Confused compare function :) Terry Reedy <tjreedy@udel.edu> - 2012-12-08 02:01 -0500
              Re: Confused compare function :) Chris Angelico <rosuav@gmail.com> - 2012-12-08 18:17 +1100
              Re: Confused compare function :) MRAB <python@mrabarnett.plus.com> - 2012-12-08 17:50 +0000
            Re: Confused compare function :) Ramchandra Apte <maniandram01@gmail.com> - 2012-12-08 19:07 -0800
              Re: Confused compare function :) Chris Angelico <rosuav@gmail.com> - 2012-12-09 14:22 +1100
                Re: Confused compare function :) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-09 07:39 +0000
            Re: Confused compare function :) Ramchandra Apte <maniandram01@gmail.com> - 2012-12-08 19:07 -0800
          Re: Confused compare function :) Neil Cerutti <neilc@norwich.edu> - 2012-12-06 13:51 +0000
            Re: Confused compare function :) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-07 02:55 +0000
              Re: Confused compare function :) Neil Cerutti <neilc@norwich.edu> - 2012-12-07 16:40 +0000
        Re: Confused compare function :) Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2012-12-06 14:33 +0100
          Re: Confused compare function :) Chris Angelico <rosuav@gmail.com> - 2012-12-07 00:58 +1100
            Re: Confused compare function :) Hans Mulder <hansmu@xs4all.nl> - 2012-12-06 15:21 +0100
              Re: Confused compare function :) Chris Angelico <rosuav@gmail.com> - 2012-12-07 01:28 +1100
          Re: Confused compare function :) Anatoli Hristov <tolidtm@gmail.com> - 2012-12-06 15:22 +0100
          Re: Confused compare function :) Dave Angel <d@davea.name> - 2012-12-06 09:40 -0500
          Re: Confused compare function :) peter <pjmakey2@gmail.com> - 2012-12-06 11:46 -0300
          Re: Confused compare function :) Anatoli Hristov <tolidtm@gmail.com> - 2012-12-06 17:16 +0100
          Re: Confused compare function :) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-12-06 16:52 +0000
          Re: Confused compare function :) Anatoli Hristov <tolidtm@gmail.com> - 2012-12-06 18:08 +0100
          Re: Confused compare function :) MRAB <python@mrabarnett.plus.com> - 2012-12-06 17:10 +0000
          Re: Confused compare function :) Anatoli Hristov <tolidtm@gmail.com> - 2012-12-06 18:31 +0100
          Re: Confused compare function :) MRAB <python@mrabarnett.plus.com> - 2012-12-06 17:52 +0000
          Re: Confused compare function :) Anatoli Hristov <tolidtm@gmail.com> - 2012-12-06 19:25 +0100
          Re: Confused compare function :) Anatoli Hristov <tolidtm@gmail.com> - 2012-12-07 14:36 +0100
        Re: Confused compare function :) Rotwang <sg552@hotmail.co.uk> - 2012-12-06 19:24 +0000
      Re: Confused compare function :) Chris Angelico <rosuav@gmail.com> - 2012-12-06 20:34 +1100
      Re: Confused compare function :) Rotwang <sg552@hotmail.co.uk> - 2012-12-06 19:25 +0000

csiph-web