Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Andrew Ongko Newsgroups: comp.lang.python Subject: Re: Howw to prevent the duplication of any value in a column within a CSV file (python) Date: Wed, 27 Apr 2016 19:57:58 +0700 Lines: 34 Message-ID: References: <75e5d8dc-e15b-4350-95e8-490abd4aa14f@googlegroups.com> <531e2dda-c522-4b11-a030-f3f37078f344@googlegroups.com> <49f4ffd8-d140-4f1b-95a9-75cb122e8b2f@googlegroups.com> <75d2b984-0a1e-42fa-bb3d-f698d4f5e0a1@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de UerSTQIdMdpTeIrQOUKmTAY3evUVS+j19irRI99yS9Gg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'else:': 0.03; 'constructor': 0.07; 'subject:file': 0.07; 'wednesday,': 0.07; 'cc:addr:python-list': 0.09; 'subject:CSV': 0.09; 'subject:python': 0.14; 'wed,': 0.15; 'subject: \n ': 0.15; '2016': 0.16; 'adam': 0.16; 'csv,': 0.16; 'forbid': 0.16; 'parentheses': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'case.': 0.18; 'pfxlen:0': 0.18; '>': 0.18; 'email addr:gmail.com>': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'cc:no real name:2**0': 0.22; 'header :In-Reply-To:1': 0.24; 'chris': 0.26; 'not.': 0.27; 'message- id:@mail.gmail.com': 0.27; 'andrew': 0.27; '"': 0.29; 'says': 0.32; "skip:' 20": 0.34; 'that,': 0.34; 'received:google.com': 0.35; 'nothing.': 0.35; 'set.': 0.35; 'item': 0.35; 'but': 0.36; 'received:209.85': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'thanks': 0.37; 'received:209': 0.38; 'mean': 0.38; 'subject:the': 0.39; 'where': 0.40; 'care': 0.60; 'your': 0.60; 'back': 0.62; 'within': 0.64; '4:26': 0.84; '7:25': 0.84; 'chrisa': 0.84; 'subject:any': 0.84; 'subject:value': 0.84; 'do:': 0.91 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; bh=U8S/VsiZ32eELMqFE1IkD2nKJZAx6Hhzgm54j1T+P8o=; b=KGHEA3+UwaG665Auc+cRTKQ/Kd/pLs85iMETW+D55D13eKLnuvQvIbd/P669Gp3IjV lmmF383020YrJYUwBy2giGs1hy863sUFt5JpY0A4/jlpvTlZnE5RuK6h1yYRHV3l9Cqd HTrfrZBZv2mY/LBzS7JMTSyZZ5FYMX2UontkrTiuFikWUo6XhudpLblyTnJpkzgnOPOk +NzbsR8keLj5NdFVF+HP4bIeBH7gIfOa+Shq9bdXIsElf+flG7qtqmeb295Yq3aSkmLf /rBQJ3IPDrlBjoSuhLU0u53jtVDocyIF3DT3jAhEpcfx1xg9jhtJ+wPh7p18cVl7d2Rq g7Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=U8S/VsiZ32eELMqFE1IkD2nKJZAx6Hhzgm54j1T+P8o=; b=iiyrcOjnmq8m8XOCpS2GoCebV1B0urZjSIMsHqDt9gfiNnz4fXM1n5/ski9k+q82rO 6qn3L/TjKS2/ClqLpod8TRqcSkd9rh4PW3PJn9LqtEvO9rbCZmkOyL2uZ0y6dCBb/19M nv1tWy6lEuHDekaV3ViJv7gQNQE5xq+d1npJdFAgKtjI7NmFWy4kcCIgOCDtS7cLbIZB ez2LRyujv2donMLKcLDvXkyv/bGj/cZSSMw6PTZYq9zYFklEZpXgjUg4cUtN2yLUNlPj vQglmEk/RCr60bY4Cvp6ett8ZGlMO9mTa2EnmrwmSyOTQQBHQgFa2AKPo3w2jeFjHyXU M9qg== X-Gm-Message-State: AOPr4FUGbc+St7K4ITwrOcQsp5G1T8MhvKn0RULVeiLe25+/086bGj7MZ7nICDuhXUU9LAzW2GXoGKRLUzfaUA== X-Received: by 10.37.97.73 with SMTP id v70mr4698970ybb.39.1461761879100; Wed, 27 Apr 2016 05:57:59 -0700 (PDT) In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <75e5d8dc-e15b-4350-95e8-490abd4aa14f@googlegroups.com> <531e2dda-c522-4b11-a030-f3f37078f344@googlegroups.com> <49f4ffd8-d140-4f1b-95a9-75cb122e8b2f@googlegroups.com> <75d2b984-0a1e-42fa-bb3d-f698d4f5e0a1@googlegroups.com> Xref: csiph.com comp.lang.python:107723 On Apr 27, 2016 7:25 PM, "Adam Davis" wrote: > > On Wednesday, 27 April 2016 07:37:42 UTC+1, Chris Angelico wrote: > > On Wed, Apr 27, 2016 at 4:26 PM, Adam Davis wrote: > > > I understand what you're saying! But where you say: " the_set = set()", what would go within the set brackets? > > > > Nothing. The empty parentheses mean "call this with no arguments", and > > when you call the set constructor like that, you get back an empty > > set. > > > > ChrisA > > Thanks Chris. Where Ian says 'the_set.add(item)', what would be put within item in terms of my codes function/aim? item is name in your case. Since it's the one you care about existing or not. It would be like: Read from csv, For each row, the_set.add(name) Now that you have the_set in memory, whenever you want to check whether a particular name has taken the quiz, just do: if name in the_set: # forbid else: # allow Regards, Andrew