Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread John Machin
On Aug 28, 7:51 am, norseman <[EMAIL PROTECTED]> wrote: > Peter Otten wrote: > > John S wrote: > > >> [OP] Jon Clements wrote: > >>> On Aug 27, 12:54 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > after reading the file throughthe csv.reader for the length I cannot > iterate over the rows.

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread norseman
Peter Otten wrote: John S wrote: [OP] Jon Clements wrote: On Aug 27, 12:54 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: after reading the file throughthe csv.reader for the length I cannot iterate over the rows. How do I reset the row iterator? A CSV file is just a text file. Don't use csv.re

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread Fredrik Lundh
John S wrote: after reading the file throughthe csv.reader for the length I cannot iterate over the rows. How do I reset the row iterator? A CSV file is just a text file. Don't use csv.reader for counting rows -- it's overkill. You can just read the file normally, counting lines (lines == row

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread Peter Otten
John S wrote: > [OP] Jon Clements wrote: >> On Aug 27, 12:54 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: >>> after reading the file throughthe csv.reader for the length I cannot >>> iterate over the rows. How do I reset the row iterator? > > A CSV file is just a text file. Don't use csv.reader fo

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread John S
[OP] Jon Clements wrote: > On Aug 27, 12:54 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: >> after reading the file throughthe csv.reader for the length I cannot >> iterate over the rows. How do I reset the row iterator? A CSV file is just a text file. Don't use csv.reader for counting rows -- it's

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread Peter Otten
Jon Clements wrote: > On Aug 27, 12:54 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: >> 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. Or 2000. Or 2

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread TYR
Use csv.DictReader to get a list of dicts (you get one for each row, with the values as the vals and the column headings as the keys) and then do a len(list)? -- http://mail.python.org/mailman/listinfo/python-list

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread SimonPalmer
On Aug 27, 1:15 pm, John Machin <[EMAIL PROTECTED]> wrote: > On Aug 27, 9: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 Br

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread John Machin
On Aug 27, 9: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 SimonPal

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread Jon Clements
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 SimonPa

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Jon Clements
On Aug 27, 12:48 pm, "Simon Brunning" <[EMAIL PROTECTED]> wrote: > 2008/8/27 Jon Clements <[EMAIL PROTECTED]>: > > >> 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

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread SimonPalmer
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

Re: finding out the number of rows in a CSV file [Resolved]

2008-08-27 Thread SimonPalmer
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

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Simon Brunning
2008/8/27 Jon Clements <[EMAIL PROTECTED]>: >> 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. -- http://mai

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Jon Clements
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,

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Jon Clements
On Aug 27, 12:16 pm, SimonPalmer <[EMAIL PROTECTED]> wrote: > 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. > > Thanks in advance You have to iterate each row and count them -- there's no other way without supporting info

Re: finding out the number of rows in a CSV file

2008-08-27 Thread Simon Brunning
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] http://www.brunningonline.net/simon/blog/ -- http://

finding out the number of rows in a CSV file

2008-08-27 Thread SimonPalmer
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. Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list