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


Groups > comp.lang.python > #44236

Re: Reading a CSV file

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 2013-04-24 00:30 +0100
Subject Re: Reading a CSV file
From Fábio Santos <fabiosantosart@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1007.1366760189.3114.python-list@python.org> (permalink)

Show all headers | 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