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 13:50:20 -0600 Lines: 21 Message-ID: References: <75e5d8dc-e15b-4350-95e8-490abd4aa14f@googlegroups.com> <514e507d-42de-400e-b999-14605c4456e8@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de CRb2CLXJ6YikRV3urfM47gD7CNEssw9cC1UdHP2ZTnNg== Return-Path: 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; 'else:': 0.03; 'received:209.85.223': 0.03; 'value,': 0.03; 'column': 0.07; 'subject:file': 0.07; 'csv': 0.09; 'subject:CSV': 0.09; 'python.': 0.11; 'subject:python': 0.14; 'do,': 0.15; 'subject: \n ': 0.15; 'value.': 0.15; '2016': 0.16; 'adam': 0.16; 'forbid': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; '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; "i'm": 0.30; '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; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:209': 0.38; 'names': 0.38; 'does': 0.39; 'subject:the': 0.39; 'enough': 0.39; 'to:addr:python.org': 0.40; '26,': 0.72; 'column.': 0.84; 'subject:any': 0.84; 'subject:value': 0.84; 'to:name:python': 0.84 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:to :content-transfer-encoding; bh=e7K4JRib6kurI0A/liGMotw1E/cpCp3E3lS6KobDs78=; b=IOi2Ch2pEKNxq7M6MIpLAu42WufF8yjpji/4Fl6wRFQyy275ogrK5wPaAmOjFg1gcM AQazli4Flct1ip/A4B1xPuMaYBfTbtZqwPl5MHJPP2ZF00siH4b4nqqaKzVGbSHVYUQz d9WfXPmXGzg0TzJHWhH9o6K8Ik6dgPSJUSHzVMAc/fi0tMP4pEXGRAdCN1ULpw1gB18I xQEY9lW389h/pg61JQfRQIkVhDV5KSUgdqeN09iEdEtvJH9hRr1AHwouBWvtdbaYW6PD H7uSC9wMpmog43Z5bJcILxfRdSHyeJrAOMpw5q5jXVusJf5DSkSxJG2KEmGD78Z8eQXz ruHg== 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:to:content-transfer-encoding; bh=e7K4JRib6kurI0A/liGMotw1E/cpCp3E3lS6KobDs78=; b=m7CXEhdwbtMvoss042MunFvwpc++MJCCx2EK1v6KXzx24XaNPJir9wddlNtbrcdl7h DVRcPEXmiCac5KFKCanTRM4OiD1PNuUiKP6KilDlgp9ANCib6aJbFukIlCYpkcLmEBSe 3WiHcgs6FWttnPXljoB3BAGdEWxdOeZ5fJ4rMI271cFw+B9PBqFQWMuPhiphlHf0kg1A AXrrOAyXRGWFoI6en4iOiAhjDPRx+iupXkfbZjrfmX/YI5JD/avA4k7IcSpYfyLqH4sv sXjIJSq73+qgwWuW3yCIM8j8ytGra4yd6oTu8ZTFzbx4NyY0BZ6dEtLBmtrYbyjmpmaZ iHqw== X-Gm-Message-State: AOPr4FW78CZ8PPSB/I1Go9aQNoG48n4H/aCEQsz4JOGbo2RFycitpCzShPV2LU/zqeNHtPOC/rPZee3K3Dgc4g== X-Received: by 10.107.171.198 with SMTP id u189mr5811119ioe.111.1461700259708; Tue, 26 Apr 2016 12:50:59 -0700 (PDT) In-Reply-To: <514e507d-42de-400e-b999-14605c4456e8@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> <514e507d-42de-400e-b999-14605c4456e8@googlegroups.com> Xref: csiph.com comp.lang.python:107684 On Tue, Apr 26, 2016 at 11:00 AM, Adam Davis wrote= : > On Tuesday, 26 April 2016 17:14:36 UTC+1, Ian wrote: >> 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 o= f the same values to be entered into a column in my CSV file created throug= h python. So I need to read into the CSV file and check if any names have a= lready been entered. If they have, the user must not be allowed to enter th= is 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. > > That's exactly what I want to do, however, I'm unsure how to check whethe= r it's in the set? if value in the_set: # Forbid the value. else: # Allow the value.