Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.040 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'true,': 0.05; 'column': 0.07; 'subject:file': 0.07; 'cc:addr:python-list': 0.11; 'iteration': 0.16; 'iteration.': 0.16; 'subject:CSV': 0.16; 'subject:Reading': 0.16; 'wrote:': 0.18; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'skip:e 30': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'too.': 0.31; 'are.': 0.31; 'allows': 0.31; 'url:python': 0.33; 'could': 0.34; 'received:google.com': 0.35; 'there': 0.35; 'url:listinfo': 0.36; 'method': 0.36; 'url:org': 0.36; 'should': 0.36; 'url:mail': 0.40; 'how': 0.40; 'read': 0.60; 'break': 0.61; 'first': 0.61; 'to:addr:gmail.com': 0.65; '8bit%:100': 0.72; 'to:charset:iso-8859-1': 0.74; '\xa0\xa0\xa0\xa0\xa0': 0.84; '\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0\xa0': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=TbRqZ8n9sL5Jl/vp9WyUYrnS+3sQ/hm0yf+Kj8y7l6Y=; b=NDiM3qwJJuH49H2jvJcwTuYSxAnPWLQXLTJLRy02r3WQP64WdfM4YGBrwAYh7Xp92R HyrdOfZ98o+qnHTRxzNo7YTecqrlmPFb4sx9Rw1vPeUJMCCE/uDBNrlmFAWAaY6BGZ/0 KvVyY8R/mEn1C+Ibk24zPevaWfHbUFMXsc5EJo5LRA4r25Yffd/1oO7uZLOtxj9iRY7F vi3NjNu7EB14Lm4FRkQvHG2Yjimyqk1McN5zviSr9y5kl8nAbie91ZNWAVTgQ2ILs6Ku 2qDw/nQpLY1K7PWj96/S9qAmtZ4xZlfakkyGEYtgQLNUtj96DfpFp+lm2NxHILNt+buv zrHQ== MIME-Version: 1.0 X-Received: by 10.229.93.71 with SMTP id u7mr11334755qcm.44.1366759813118; Tue, 23 Apr 2013 16:30:13 -0700 (PDT) In-Reply-To: <54f430e9-b0f0-42ab-86c3-37dfb3bc45bd@googlegroups.com> References: <9d0d46e5-b579-4edc-be34-0aa8798b66f8@googlegroups.com> <665fa76f-3a19-414b-8524-c2a5bfa8b21b@googlegroups.com> <54f430e9-b0f0-42ab-86c3-37dfb3bc45bd@googlegroups.com> Date: Wed, 24 Apr 2013 00:30:12 +0100 Subject: Re: Reading a CSV file From: =?ISO-8859-1?Q?F=E1bio_Santos?= To: =?ISO-8859-1?Q?Ana_Dion=EDsio?= Content-Type: multipart/alternative; boundary=001517503b32279cd304db0f9178 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: 55 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366760189 news.xs4all.nl 2187 [2001:888:2000:d::a6]:34677 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:44236 --001517503b32279cd304db0f9178 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable The enumerate function should allow you to check whether you are in the first iteration. Like so: for row_number, row in enumerate(csv.reader(<...>)): if enumerate =3D=3D 0: if : break ... Enumerate allows you to know how far into the iteration you are. You could use the iterator's next() method too. On 23 Apr 2013 23:53, "Ana Dion=EDsio" wrote: > > The condition I want to meet is in the first column, so is there a way to read only the first column and if the condition is true, print the rest? > -- > http://mail.python.org/mailman/listinfo/python-list --001517503b32279cd304db0f9178 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

The enumerate function should allow you to check whether you= are in the first iteration.

Like so:

=A0=A0=A0=A0=A0 for row_number, row in enumerate(csv.reader(= <...>)):
=A0=A0=A0=A0=A0=A0=A0=A0=A0 if enumerate =3D=3D 0:
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 if <your check...>:
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 break
=A0=A0=A0=A0=A0=A0=A0=A0=A0 ...

Enumerate allows you to know how far into the iteration you = are.

You could use the iterator's next() method too.

On 23 Apr 2013 23:53, "Ana Dion=EDsio" <anadionisio257@gmail.com> wrote= :
>
> The condition I want to meet is in the first column, so is there a way= to read only the first column and if the condition is true, print the rest= ?
> --
> http:/= /mail.python.org/mailman/listinfo/python-list

--001517503b32279cd304db0f9178--