finding out the number of rows in a CSV file

Jon Clements joncle at googlemail.com
Wed Aug 27 07:56:22 EDT 2008


On Aug 27, 12:48 pm, "Simon Brunning" <si... at brunningonline.net>
wrote:
> 2008/8/27 Jon Clements <jon... at googlemail.com>:
>
> >> len(list(csv.reader(open('my.csv'))))
> > Not the best of ideas if the row size or number of rows is large!
> > Manufacture a list, then discard to get its length -- ouch!
>
> I do try to avoid premature optimization. ;-)
>
> --
> Cheers,
> Simon B.

:)



More information about the Python-list mailing list