Number of cells, using CSV module
Tim Chase
python.list at tim.thechases.com
Thu May 16 16:00:21 EDT 2013
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
More information about the Python-list
mailing list