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


Groups > comp.lang.python > #48616

Re: Help me with the script? How to find items in csv file A and not in file B and vice versa

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <andipersti@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'syntax': 0.04; 'newbie': 0.05; 'subject:file': 0.07; 'subject:script': 0.09; 'subject:How': 0.10; 'subject:Help': 0.11; '"in"': 0.16; 'andreas': 0.16; 'bye,': 0.16; 'highlighted': 0.16; 'skip:^ 20': 0.16; 'subject: \n ': 0.16; 'wrote:': 0.18; 'error': 0.23; 'header:In-Reply-To:1': 0.27; 'thus': 0.29; 'run': 0.32; 'subject:the': 0.34; 'subject:with': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'charset:us-ascii': 0.36; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'subject:? ': 0.60; 'email addr:gmail.com': 0.63; 'invalid': 0.68; 'subject:find': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; bh=0YhXz0aZBFDPCa9LsjnngiyzPjEM5LINH3O8Lf9jUyY=; b=cxjBU2FdSk19uyysu8Sq83bX/C0u8y2WGyC21DoITEhTwbQQtgRJDuPLP7AePyyjzw h7fwC4RBJwd7O3OwNCDejEQIKDQYWT9r1w1l7EikPVjUErimBqshRjoHJJLHzzBeD6Uy DadNjo3/60B2U1aSP5E2eemJePLsbFjXskgWgsEwsl8dyvGNuzp/APbLGmHdPdZNJrEa yr0Qn0+jPVBVg2RKZvbUKrJrcrBbXl3CQTC13O0hntoGvAlOpo12fAAQs0ccJ9T7KT2X J6Gbg5ftDxFTkF5ikc9XkpkgWwSgzwOc2X1a2Z+7qL87PetgmTp+Rhsg2HVQmTY08i8Y Z4+A==
X-Received by 10.14.29.69 with SMTP id h45mr19876596eea.127.1371550464496; Tue, 18 Jun 2013 03:14:24 -0700 (PDT)
Date Tue, 18 Jun 2013 12:14:21 +0200
From Andreas Perstinger <andipersti@gmail.com>
To python-list@python.org
Subject Re: Help me with the script? How to find items in csv file A and not in file B and vice versa
In-Reply-To <10d49cd4-90a9-4a9f-822e-207c87dafa50@googlegroups.com>
References <8390d9db-a670-4f39-81cb-34c14b59d29b@googlegroups.com> <mailman.3515.1371544747.3114.python-list@python.org> <10d49cd4-90a9-4a9f-822e-207c87dafa50@googlegroups.com>
X-Mailer Claws Mail 3.7.9 (GTK+ 2.24.6; i686-pc-linux-gnu)
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
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.3522.1371550472.3114.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1371550472 news.xs4all.nl 15890 [2001:888:2000:d::a6]:60214
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:48616

Show key headers only | View raw


alonnirs@gmail.com wrote:
>and when I run it I get an invalid syntex error and (as a true newbie
>I used a GUI)in_a_not_b is highlighted in the with open("inAnotB.csv",
>"wb") as f: 
>    writer = csv.writer(f) 
>    writer.writerows([item] for item in_a_not_b)
                             ^^^^^^^^^^^^^^^^^^^^

The syntax for the for-clause in a comprehension is

for x in something

thus you are missing the "in" keyword:

writer.writerows([item] for item in in_a_not_b)

Bye, Andreas

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


Thread

Help me with the script? How to find items in csv file A and not in file B and vice versa Alan Newbie <alonnirs@gmail.com> - 2013-06-18 01:01 -0700
  Re: Help me with the script? How to find items in csv file A and not in file B and vice versa Peter Otten <__peter__@web.de> - 2013-06-18 10:39 +0200
    Re: Help me with the script? How to find items in csv file A and not in file B and vice versa alonnirs@gmail.com - 2013-06-18 02:01 -0700
      Re: Help me with the script? How to find items in csv file A and not in file B and vice versa Andreas Perstinger <andipersti@gmail.com> - 2013-06-18 12:14 +0200
        Re: Help me with the script? How to find items in csv file A and not in file B and vice versa Alan Newbie <alonnirs@gmail.com> - 2013-06-18 03:48 -0700

csiph-web