Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #44236

Re: Reading a CSV file

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 <fabiosantosart@gmail.com>
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&gt;': 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; '&gt;': 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> <mailman.1000.1366753795.3114.python-list@python.org> <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 Fábio Santos <fabiosantosart@gmail.com>
To Ana Dionísio <anadionisio257@gmail.com>
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 <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1007.1366760189.3114.python-list@python.org> (permalink)
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

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

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 == 0:
              if <your check...>:
                  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ísio" <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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Reading a CSV file Ana Dionísio <anadionisio257@gmail.com> - 2013-04-23 14:39 -0700
  Re: Reading a CSV file Dan Stromberg <drsalists@gmail.com> - 2013-04-23 14:49 -0700
    Re: Reading a CSV file Ana Dionísio <anadionisio257@gmail.com> - 2013-04-23 14:58 -0700
      Re: Reading a CSV file Ana Dionísio <anadionisio257@gmail.com> - 2013-04-23 15:40 -0700
        Re: Reading a CSV file Fábio Santos <fabiosantosart@gmail.com> - 2013-04-24 00:30 +0100
        Re: Reading a CSV file Dave Angel <davea@davea.name> - 2013-04-23 23:18 -0400
      Re: Reading a CSV file Dan Stromberg <drsalists@gmail.com> - 2013-04-23 15:34 -0700

csiph-web