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


Groups > comp.lang.python > #45454

Re: Number of cells, using CSV module

Date 2013-05-16 15:00 -0500
From Tim Chase <python.list@tim.thechases.com>
Subject Re: Number of cells, using CSV module
References <5f4aec0e-5cfa-445f-af50-67cca7caae36@googlegroups.com> <mailman.1769.1368729617.3114.python-list@python.org> <8662be9c-e50c-48e9-86dc-1838c6188d0c@googlegroups.com> <CANc-5UxXaijcEDDM7moKn=KphRco5S+fA+innG1PQ4EM=W0PPQ@mail.gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1775.1368734307.3114.python-list@python.org> (permalink)

Show all headers | View raw


On 2013-05-16 14:07, Skip Montanaro wrote:
> > len(reader) gives me an error.
> 
> Apologies.  len(list(reader)) should work.  Of course, you'll wind
> up loading the entire CSV file into memory.  You might want to just
> count row-by-row:
> 
> n = 0
> for row in reader:
>     n += 1

which can nicely be rewritten as

  n = sum(1 for row in reader)

:-)

-tkc

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


Thread

Number of cells, using CSV module tunacubes@gmail.com - 2013-05-16 11:29 -0700
  Re: Number of cells, using CSV module Skip Montanaro <skip@pobox.com> - 2013-05-16 13:40 -0500
    Re: Number of cells, using CSV module tunacubes@gmail.com - 2013-05-16 11:50 -0700
      Re: Number of cells, using CSV module Skip Montanaro <skip@pobox.com> - 2013-05-16 14:07 -0500
      Re: Number of cells, using CSV module Tim Chase <python.list@tim.thechases.com> - 2013-05-16 15:00 -0500
  Re: Number of cells, using CSV module tunacubes@gmail.com - 2013-05-16 11:53 -0700
    Re: Number of cells, using CSV module Skip Montanaro <skip@pobox.com> - 2013-05-16 14:08 -0500
    Re: Number of cells, using CSV module Tim Chase <python.list@tim.thechases.com> - 2013-05-16 15:01 -0500
  Re: Number of cells, using CSV module tunacubes@gmail.com - 2013-05-16 13:11 -0700

csiph-web