Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: Howw to prevent the duplication of any value in a column within a CSV file (python) Date: Tue, 26 Apr 2016 10:13:38 -0600 Lines: 10 Message-ID: References: <75e5d8dc-e15b-4350-95e8-490abd4aa14f@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de IJDjUelyL3wWalvleXXwLwzyI5eltA/95OgovLR80Jsw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'value,': 0.03; 'column': 0.07; 'subject:file': 0.07; 'cc:addr:python-list': 0.09; 'csv': 0.09; 'subject:CSV': 0.09; 'python.': 0.11; 'subject:python': 0.14; 'subject: \n ': 0.15; 'value.': 0.15; '2016': 0.16; 'cc:name:python': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'assuming': 0.22; 'am,': 0.23; 'fit': 0.23; 'header:In-Reply- To:1': 0.24; 'wondering': 0.25; 'entered': 0.27; 'message- id:@mail.gmail.com': 0.27; 'have,': 0.27; 'function': 0.28; 'values': 0.28; 'code': 0.30; 'tue,': 0.34; 'file': 0.34; 'received:google.com': 0.35; 'set.': 0.35; 'created': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'names': 0.38; 'does': 0.39; 'subject:the': 0.39; 'enough': 0.39; '26,': 0.72; 'column.': 0.84; 'subject:any': 0.84; 'subject:value': 0.84; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc :content-transfer-encoding; bh=afM0VzvRokj48wcxUH2e1e/OsRBuY2mzP/QYU1k0V44=; b=xG7+piEQ/pvMhQC0KMnWUrIYkhMIF6DDJersJlP03Hmw5ib/eDDUW2tICjHouYj6Ha /uAlRA+O2aOPA8w+JXfbovziKCzP0R/P/F6g0p5fUrqw+VjPqckBCW28lel5PJKyUqqo s/7z3b+H/46ieVrwrPhOrrovRoR4TxtPiXaxuCXm23ZcTK3rJdlV8tTiV0Ez1nviReVR AWlxIuzP1x7aBVFTPDYVElMzsbgqqMjwvi8nNYEjtXp9/EIl3zj3ljc8tpvrQXvtSWqo Dsvkt4dNc71NyuU7DoJUE/fkCidNC/ZomhkCYsAHitzRsvBh/eEkjoRSZPJw6/LIm/Di PMvg== 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:from:date :message-id:subject:cc:content-transfer-encoding; bh=afM0VzvRokj48wcxUH2e1e/OsRBuY2mzP/QYU1k0V44=; b=F7XT5dqVA4zBjN2ujfQG4aGFjipY9KXNnZRR3ap6KdEutlorzN5kox8yi1hyEHFh1a n9fxtDuIvxbIaPyOyGcZKjY8ih3Il7HPsK5SAl3JzrbO6LKWwMXouZ3DSb9mDkPXGRSb Ajl9ee00pVCO1DvvFQLkTtSccq7zjanr3L+D9H2SZckgjNgzBf3Ne5wRxwKvHGDWF6H0 ADUXzn2xh3ea5UhaqOkraP9j5OhybMdB04z2AFfYnuEn4uLBM22OPzVp1hWtkw9ZeBr7 TPqCbXza2f41heEZNVXMOrHgYt67zfkBmIQOrVdbmK/Sf0+nU36BUEZ338TMZP3okjfd 3YlA== X-Gm-Message-State: AOPr4FXy/Q3emWj4WOJs4Nboyd+RDIGJOCj8Kzb+KEAviUxbeZ39Gh+gf2X2hLdnImwiA2gJUMs/1FZ5cmRT0A== X-Received: by 10.50.26.169 with SMTP id m9mr19948995igg.68.1461687258184; Tue, 26 Apr 2016 09:14:18 -0700 (PDT) In-Reply-To: <75e5d8dc-e15b-4350-95e8-490abd4aa14f@googlegroups.com> 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> Xref: csiph.com comp.lang.python:107665 On Tue, Apr 26, 2016 at 10:01 AM, wrote: > I am wondering how to make my code function so it does not allow any of t= he same values to be entered into a column in my CSV file created through p= ython. So I need to read into the CSV file and check if any names have alre= ady been entered. If they have, the user must not be allowed to enter this = value. Assuming the file is reasonably small enough to fit into memory, create a set and populate it with the values in the column. When the user enters a new value, check whether it's already in the set.