Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'output': 0.04; 'discard': 0.05; 'cc:addr:python-list': 0.10; 'resulting': 0.13; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'headers,': 0.16; 'optionally': 0.16; 'row': 0.16; 'subject:reader': 0.16; 'tempted': 0.16; 'typo': 0.16; 'wrote:': 0.17; "i'd": 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'correct': 0.28; 'sense': 0.31; 'print': 0.32; 'data,': 0.35; 'add': 0.36; 'charset:us-ascii': 0.36; 'display': 0.36; 'operating': 0.36; 'data': 0.37; 'subject:: ': 0.38; 'store': 0.38; 'fact': 0.38; 'your': 0.60; 'first': 0.61; 'more': 0.63; 'here': 0.65; 'received:50.22': 0.84; 'angel': 0.93 Date: Sun, 24 Mar 2013 08:49:22 -0500 From: Tim Chase To: Dave Angel Subject: Re: Separate Rows in reader In-Reply-To: <514EF9A3.2000603@davea.name> References: <5a1660c3-ca17-452c-ae0f-ee61f4319a8f@googlegroups.com> <514EF9A3.2000603@davea.name> X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364132867 news.xs4all.nl 6903 [2001:888:2000:d::a6]:55703 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41782 On 2013-03-24 09:03, Dave Angel wrote: > >> [THANK YOU!] > > Sorry my typo in the output here is the correct output that i > > need : > > > > [('John Konon', 'Ministry of moon Walks', '4567882', '27-Feb'), > > ( 'Stacy Kisha', 'Ministry of Man Power', '1234567', 17-Jan')] > > > > the difference is that i need a [(row two), (row three), (row > > fouth)] . I do not want to display row one which is ['Name', ' > > Address', 'Telephone', 'Birthday'] > > I had to add a delimiter= to accomodate the fact that your data is > tab- separated. Since it has headers, it might make more sense for readability to use a DictReader: f = file("source.txt", "rb") r = csv.DictReader(f, delimiter='\t') for row in r: print row["Name"], row["Address"], ... However, if it's just stripping off the first row and operating directly on the resulting data, then I'd just be tempted to do r = csv.reader(f, delimiter='\t') r.next() # discard the headers, or optionally store them for row in r: ... -tkc