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: 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 To: Skip Montanaro Subject: Re: Number of cells, using CSV module In-Reply-To: References: <5f4aec0e-5cfa-445f-af50-67cca7caae36@googlegroups.com> <8662be9c-e50c-48e9-86dc-1838c6188d0c@googlegroups.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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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