On Aug 27, 12:54 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > On Aug 27, 12:50 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > > > > > On Aug 27, 12:41 pm, Jon Clements <[EMAIL PROTECTED]> wrote: > > > > On Aug 27, 12:29 pm, "Simon Brunning" <[EMAIL PROTECTED]> > > > wrote: > > > > > 2008/8/27 SimonPalmer <[EMAIL PROTECTED]>: > > > > > > anyone know how I would find out how many rows are in a csv file? > > > > > > I can't find a method which does this on csv.reader. > > > > > len(list(csv.reader(open('my.csv')))) > > > > > -- > > > > Cheers, > > > > Simon B. > > > > [EMAIL PROTECTED]://www.brunningonline.net/simon/blog/ > > > > 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! > > > Thanks to everyone for their suggestions. > > > In my case the number of rows is never going to be that large (<200) > > so it is a practical if slightly inelegant solution > > actually not resolved... > > after reading the file throughthe csv.reader for the length I cannot > iterate over the rows. How do I reset the row iterator?
If you're sure that the number of rows is always less than 200. Slightly modify Simon Brunning's example and do: rows = list( csv.reader(open('filename.csv')) ) row_count = len(rows) for row in rows: # do something -- http://mail.python.org/mailman/listinfo/python-list