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


Groups > comp.lang.python > #45454

Re: Number of cells, using CSV module

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'memory.': 0.07; 'nicely': 0.07; 'subject:Number': 0.09; 'subject:module': 0.09; 'subject:using': 0.09; 'to:addr:pobox.com': 0.09; 'to:addr:skip': 0.09; 'cc:addr:python-list': 0.11; '-tkc': 0.16; 'csv': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'rewritten': 0.16; 'subject:CSV': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'cc:addr:gmail.com': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**1': 0.23; 'skip': 0.24; 'header:In-Reply-To:1': 0.27; 'work.': 0.31; 'gives': 0.31; 'loading': 0.31; 'wind': 0.31; 'file': 0.32; 'cc:no real name:2**1': 0.33; 'charset:us-ascii': 0.36; 'should': 0.36; 'error.': 0.37; 'entire': 0.61; "you'll": 0.62; 'received:50.22': 0.84
Date Thu, 16 May 2013 15:00:21 -0500
From Tim Chase <python.list@tim.thechases.com>
To Skip Montanaro <skip@pobox.com>
Subject Re: Number of cells, using CSV module
In-Reply-To <CANc-5UxXaijcEDDM7moKn=KphRco5S+fA+innG1PQ4EM=W0PPQ@mail.gmail.com>
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>
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 tunacubes@gmail.com, 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.1775.1368734307.3114.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1368734307 news.xs4all.nl 15978 [2001:888:2000:d::a6]:47155
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:45454

Show key headers only | 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